user9484528
user9484528

Reputation: 347

ArangoSearch on JSONarray objects

I am trying to use arango search on nested json array object in a view. it works fine on single non array json fields. but craps out when search is on a json array.

Sample JSON object

{
    "_key": "xx1sdas",
    "itemId": "xx1",
    "parent": [{
        "childId": "t1",
        "childName": "kai"
    }, {
        "childId": "t2",
        "childName": "tom"
    }]
}

The error message is not much helpful too Query: AQL: not implemented: Unable to evaluate loop variable 'item' as a part of ArangoSearch noncompliant expression '_EXPANSION(_ITERATOR($0.parent,$2),$2.childName,) == "tom"' (while executing)

FOR item IN itemsView
  SEARCH ANALYZER(item.parent[*].childName IN TOKENS('tom', 'text_en'), 'text_en')
  SORT BM25(item) DESC 
  LIMIT 10 
RETURN item

Upvotes: 1

Views: 465

Answers (1)

user9484528
user9484528

Reputation: 347

figured out that in arangosearch, there is no need to expand jsonarray. the below query worked for me.

FOR item IN iView
  SEARCH ANALYZER(item.parent.childName IN TOKENS('tom', 'text_en'), 'text_en')
  SORT BM25(item) DESC 
  LIMIT 10 
RETURN item

reference: https://github.com/arangodb/arangodb/issues/9616

Upvotes: 3

Related Questions