简体   繁体   中英

Is it possible to index all attributes without knowing exact structure beforehand in arangodb?

I have a collection with simple documents like this

{
key1:value,
key2:value2,
....
}

I would like to index all keys separately.

But the current arangodb UI only provide a list of attributes seperated by comma, eg. [key1,key2] as input. So I have to define those attributes beforehand

Is there something like * to tell arango to index all attributes.

The standard indexes do not support wildcards to index all attributes (and multiple paths in an index definition will create a combined index, not a union of all keys). But you can create an ArangoSearch View and let it index all attributes:

{
  "type": "arangosearch",
  "links": {
    "coll": {
      "analyzers": [
        "identity"
      ],
      "includeAllFields": true
    }
  }
}

Then add some documents into the collection coll :

  • {"foo": 1}
  • {"bar": 2}
  • {"baz": {"nested": 3} }

And finally query the View (here called someView ), using the default identity Analyzer:

FOR doc IN someView
  SEARCH doc.baz.nested == 3
  RETURN doc

As you can see, all attributes including nested ones are indexed by the using the includeAllFields option at the top-level.

More info: https://www.arangodb.com/docs/stable/arangosearch.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM