arangodb - 如何将两个分析器包含到单个 SEARCH 语句中?
问题描述
我有一个feeds
包含这样的文档的集合:
{
"created": 1510000000,
"find": [
"title of the document",
"body of the document"
],
"filter": [
"/example.com",
"-en"
]
}
created
包含一个纪元时间戳find
包含一个全文片段数组,例如文本的标题和正文filter
是一个包含更多搜索标记的数组,例如主题标签、域、语言环境
问题是它find
包含全文片段,我们想要对其进行标记,例如使用text
分析器,但filter
包含我们想要作为一个整体比较的最终标记,例如使用identity
分析器。
目标是合并find
到filter
一个自定义分析器中,或者使用两个 SEARCH 语句或其他东西来合并两个分析器。
我确实设法通过其中一个find
或通过filter
成功进行查询,但没有设法通过两者进行查询。这就是我查询的方式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
是视图语法中的一个数组,但我似乎无法为每个分析器设置单独的字段。
解决方案
分析器可以作为属性添加到fields
. 中指定的analyzers
是默认值,用于未为给定字段设置更具体的分析器的情况。
"analyzers": [
"identity"
],
"fields": {
"find": {
"analyzers": [
"text_en"
]
},
"filter": {},
"created": {}
},
致谢:ArangoDB 的 Simran
推荐阅读
- c# - 如何确保 Thread.Sleep() 是同步的?
- networking - 创建 Kubernetes Pod 网络映射
- python-3.x - 命令在 vscode powershell 终端中不起作用
- python - 打印一个 numpy 数组列表
- html - 反应组件高度
- javascript - 播放 webm 块流时音频不同步
- dataframe - 使用 groupBy() 的 pySpark 子数据帧
- python - 如何用另一个字典数组中的元素替换一个字典中的值数组
- amazon-web-services - 使用 SSE 加密的 boto3 generate_presigned_url
- c# - 如何处理来自触发事件的重叠 Console.Writeline()?