ArangoDB 如何在一条SEARCH语句中包含两个分析器?

ryoqjall  于 2022-12-09  发布在  Go
关注(0)|答案(1)|浏览(123)

我有一个feeds集合,其中的文档如下所示:

{
  "created": 1510000000,
  "find": [
    "title of the document",
    "body of the document"
  ],
  "filter": [
    "/example.com",
    "-en"
  ]
}
  • created包含纪元时间戳
  • find包含全文代码段数组,例如文本的标题和正文
  • filter是包含更多搜索标记(如散列标签、域、区域设置)的数组

问题是find包含全文片段,我们希望将其标记化,例如使用text分析器,但filter包含最终标记,我们希望将其作为一个整体进行比较,例如使用identity分析器。
目标是将findfilter合并到一个自定义分析器中,或者使用两个SEARCH语句或其他方法将两个分析器合并到一起。
我成功地按findfilter进行了查询,但没有同时按这两种方式进行查询。下面是我按filter进行查询的方法:
我创建了一个feeds_search视图:

{
  "writebufferIdle": 64,
  "type": "arangosearch",
  "links": {
    "feeds": {
      "analyzers": [
        "identity"
      ],
      "fields": {
        "find": {},
        "filter": {},
        "created": {}
      },
      "includeAllFields": false,
      "storeValues": "none",
      "trackListPositions": false
    }
  },
  "consolidationIntervalMsec": 10000,
  "writebufferActive": 0,
  "primarySort": [],
  "writebufferSizeMax": 33554432,
  "consolidationPolicy": {
    "type": "tier",
    "segmentsBytesFloor": 2097152,
    "segmentsBytesMax": 5368709120,
    "segmentsMax": 10,
    "segmentsMin": 1,
    "minScore": 0
  },
  "cleanupIntervalStep": 2,
  "commitIntervalMsec": 1000,
  "id": "362444",
  "globallyUniqueId": "hD6FBD6EE239C/362444"
}

并创建了一个示例查询:

FOR feed IN feeds_search
SEARCH ANALYZER(feed.created < 9990000000 AND feed.created > 1500000000 
AND (feed.find == "title of the document")
AND (feed.`filter` == "/example.com" OR feed.`filter` == "-uk"), "identity")
SORT feed.created
LIMIT 20
RETURN feed

示例查询可以工作,因为find包含完整文本(identity分析器)。一旦切换到text分析器,单个单词标记对find有效,但filter不再有效。
我尝试使用SEARCH和FILTER的组合,这给了我想要的结果,但我认为它的性能可能比让SEARCH分析器做整个事情要差。我看到analyzers在视图语法中是一个数组,但我似乎不能为每个分析器设置单独的字段。

tyky79it

tyky79it1#

分析器可以作为属性添加到fields中的每个字段。在analyzers中指定的是默认值,在没有为给定字段设置更具体的分析器时使用。

"analyzers": [
        "identity"
      ],
      "fields": {
        "find": {
          "analyzers": [
            "text_en"
          ]
        },
        "filter": {},
        "created": {}
      },
  • 制作人员:ArangoDB的Simran *

相关问题