问题
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