我有一个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
在视图语法中是一个数组,但我似乎不能为每个分析器设置单独的字段。
1条答案
按热度按时间tyky79it1#
分析器可以作为属性添加到
fields
中的每个字段。在analyzers
中指定的是默认值,在没有为给定字段设置更具体的分析器时使用。