How to use full text search with arango REST API as I'm always getting empty result?

风流意气都作罢 提交于 2019-12-23 22:01:21

问题


Data in Arango:

{
 "employees": [
    {
      "lastName": "Ansari",
      "firstName": "Haseb"
    },
    {
      "lastName": "Ansari",
      "firstName": "Affan"
    },
    {
      "lastName": "Keshav",
      "firstName": "Anil"
    }
  ],
  "_id": "test/124518952473",
  "_rev": "124518952473",
  "_key": "124518952473"
}

Indexing: POST http://localhost:8529/_db/db_test/_api/index?collection=test

Body:

{
 "type" : "fulltext", 
 "fields" : [ 
   "lastName" 
  ] 
}

Searching:

PUT http://localhost:8529/_db/db_test/_api/simple/fulltext

Body:

{ 
  "collection" : "test", 
  "attribute" : "lastName", 
  "query" : "Ansari" 
}

I want in my application to use REST API for full text search. Please help me where I am going wrong here. And this is one document in arango store just for example. Otherwise, i'll be having more documents hence full-text search.


回答1:


Short: Your index is not on a field in your document.

Long: You're saving one document, it has a list employees, but no document lastname - thats inside of employees but this won't match the path.

You can however make it work if you put the fulltext index on employees, then all attributes of the object employees will be indexed. You then however will match on first and last name.

If you want to do this separate, you need to directly match a token like that: employees[0].lastName



来源:https://stackoverflow.com/questions/34780431/how-to-use-full-text-search-with-arango-rest-api-as-im-always-getting-empty-res

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!