简体   繁体   English

无法在 ArangoDB 中正常工作的 ArangoSearch 视图

[英]Unable to get an ArangoSearch view working properly in ArangoDB

I'm having trouble with ArangoSearch.我在使用 ArangoSearch 时遇到问题。

Here is some dummy data that I have in a collection called things (for simplicity I have removed each of their "_id", "_key" and "_rev" properties):这是我在一个名为things的集合中的一些虚拟数据(为简单起见,我删除了它们的每个“_id”、“_key”和“_rev”属性):

{"text":"eat a cookie"}
 
{"text":"I like cookies"}
 
{"text":"Timmy how are u"}
 
{"text":"I read a book on elves"}

And I have a view that looks like this (I am calling it practice ):我有一个看起来像这样的视图(我称之为practice ):

{
  "writebufferIdle": 64,
  "type": "arangosearch",
  "primarySortCompression": "lz4",
  "links": {
    "things": {
      "analyzers": [
        "text_en",
        "identity"
      ],
      "fields": {
        "text": {
          "analyzers": [
            "text_en"
          ]
        }
      },
      "includeAllFields": true,
      "storeValues": "none",
      "trackListPositions": false
    }
  },
  "primarySort": [],
  "writebufferSizeMax": 33554432,
  "consolidationPolicy": {
    "type": "tier",
    "segmentsBytesFloor": 2097152,
    "segmentsBytesMax": 5368709120,
    "segmentsMax": 10,
    "segmentsMin": 1,
    "minScore": 0
  },
  "cleanupIntervalStep": 2,
  "commitIntervalMsec": 1000,
  "storedValues": [],
  "id": "138993",
  "globallyUniqueId": "h23A40B2F96C2/138993",
  "writebufferActive": 0,
  "consolidationIntervalMsec": 1000
}

When I do an AQL search like follows, it correctly returns 4:当我进行如下 AQL 搜索时,它正确返回 4:

FOR docs IN practice COLLECT WITH COUNT INTO num RETURN num

But when I do an AQL search like this, I mostly get empty arrays:但是当我像这样进行 AQL 搜索时,我通常会得到空数组:

FOR doc IN practice
SEARCH ANALYZER(doc.text == "cookie", "text_en")
RETURN doc

(weirdly, there is a word or two that works with the above but a majority don't - for example, "cookie" returns an empty array but "how" returns one match) (奇怪的是,有一两个词适用于上述内容,但大多数人不适用 - 例如,“cookie”返回一个空数组,但“how”返回一个匹配项)

Any idea what I am doing wrong?知道我做错了什么吗?

Thanks谢谢

The indexed text field has text_en processing applied but you aren't applying it to the search term.索引text字段已应用text_en处理,但您并未将其应用于搜索词。

ANALYZER(doc.text == "cookie", "text_en")

The ANALYZER() function only selects the analyzer for the indexed data here. ANALYZER()函数只为此处的索引数据选择分析器。

Depending on how the analyzer transforms the stored attribute values, there can be a mismatch because of stemming.根据分析器如何转换存储的属性值,可能会因词干提取而出现不匹配。 All of the built-in text analyzers have stemming enabled.所有内置的文本分析器都启用了词干提取。

Try RETURN TOKENS("cookie", "text_en") to see what the analyzer does to the word.尝试RETURN TOKENS("cookie", "text_en")以查看分析器对单词做了什么。

This should find two things:这应该发现两件事:

ANALYZER(doc.text == TOKENS("cookie", "text_en")[0], "text_en")

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

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