1

My data:

{
  "rootElement": {
    "names": {
      "name": [
        "Haseb",
        "Anil",
        "Ajinkya",
        {
          "city": "mumbai",
          "state": "maharashtra",
          "job": {
            "second": "bosch",
            "first": "infosys"
          }
        }
      ]
    },
    "places": {
      "place": {
        "origin": "INDIA",
        "current": "GERMANY"
      }
    }
  }
}

I created a hash index on job field with the API:
http://localhost:8529/_db/_api/index?collection=Metadata

{
  "type": "hash",
  "fields": [
    "rootElement.names.name[*].jobs"
  ]
}

And I make the search query with the API:
http://localhost:8529/_db/_api/simple/by-example

{
  "collection": "Metadata",
  "example": {
    "rootElement.names.name[*].jobs ": "bosch"
  }
}

Ideally, only the document containing job : bosch should be returned as a result. But for me it gives all the documents in the array name[*]. Where I am doing mistake?

3
  • first hint: you should avoid simple queries if you can. Commented Feb 15, 2016 at 12:02
  • but it is the straight forward query for search Commented Feb 15, 2016 at 12:58
  • Did the answer fullfill your needs? If not, whats missing? If, can you mark it accepted? Commented Apr 25, 2016 at 15:11

1 Answer 1

1

Array asterisk operators are not supported by simple queries.

You need to use AQL for this:

FOR elem IN Metadata FILTER elem.rootElement.names.name[*].jobs = "bosch" RETURN elem

You can also execute AQL via the REST interface - However you should rather try to let a driver do the heavy lifting for you.

Sign up to request clarification or add additional context in comments.

2 Comments

does in any way Arango handle nested array for fulltext indexing & searching ?
The 'translation' exampl demonstates the capabilities of the fulltext index. Deeper nesting is currently unsupported.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.