简体   繁体   English

如何在 arango REST API 中使用全文搜索,因为我总是得到空结果?

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

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索引: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 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.我希望在我的应用程序中使用 REST API 进行全文搜索。 Please help me where I am going wrong here.请帮助我在这里出错的地方。 And this is one document in arango store just for example.例如,这是 arango 商店中的一份文件。 Otherwise, i'll be having more documents hence full-text search.否则,我将拥有更多文档,因此进行全文搜索。

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.长:您正在保存一个文档,它有一个列表employees ,但没有文档lastname - 这是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.但是,如果将全文索引放在employees ,则可以使其工作,然后对象employees所有属性都将被索引。 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如果要单独执行此操作,则需要直接匹配这样的标记: employees[0].lastName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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