问题描述
Arango 中的数据:
Data in Arango:
{
"employees": [
{
"lastName": "Ansari",
"firstName": "Haseb"
},
{
"lastName": "Ansari",
"firstName": "Affan"
},
{
"lastName": "Keshav",
"firstName": "Anil"
}
],
"_id": "test/124518952473",
"_rev": "124518952473",
"_key": "124518952473"
}
索引:POST http://localhost:8529/_db/db_test/_api/index?collection=测试
身体:
{
"type" : "fulltext",
"fields" : [
"lastName"
]
}
搜索:
PUT http://localhost:8529/_db/db_test/_api/simple/fulltext
身体:
{
"collection" : "test",
"attribute" : "lastName",
"query" : "Ansari"
}
我希望在我的应用程序中使用 REST API 进行全文搜索.请帮助我在这里出错的地方.例如,这是 arango 商店中的一份文件.否则,我将拥有更多文档,因此进行全文搜索.
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.
推荐答案
简短:您的索引不在文档的某个字段上.
Short: Your index is not on a field in your document.
长:您正在保存一个文档,它有一个列表 employees
,但没有文档 lastname
- 位于 employees
内,但这与路径.
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.
然而,如果您将全文索引放在employees
上,则可以使其工作,然后对象employees
的所有属性都将被索引.但是,您将匹配名字 和 姓氏.
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.
如果你想单独这样做,你需要直接匹配这样的令牌:employees[0].lastName
If you want to do this separate, you need to directly match a token like that:employees[0].lastName
这篇关于如何在 arango REST API 中使用全文搜索,因为我总是得到空结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!