我正在寻找在snippet中获取所有匹配项的方法。但是我得到的结果不完整。我已将maxSnippetChars,maxMatches,perMatchTokens值设置为max。文档的结构是一个对象数组,我要为所有满足匹配条件的匹配对象的属性(摘要)提供路径。你能帮我一下吗 我正在使用以下代码:-
.where(jsearch.byExample({"$query":{Synopsis:{"$word":"word","$case-sensitive":false}}}))
.slice(0, Number.MAX_SAFE_INTEGER)
.map({
snippet: {
maxSnippetChars:Number.MAX_SAFE_INTEGER,
maxMatches:Number.MAX_SAFE_INTEGER,
perMatchTokens: Number.MAX_SAFE_INTEGER
}, extract: {paths: ['/ID','/FullName']}
}
)
.result() ```
如果您打算配置代码片段生成器属性,则可以在jsearch管道中调整内置映射器的顺序,如下所示:
.where(jsearch.byExample({synopsis: {$word: 'word'}}))
.slice(0, 15)
.map({extract: {paths: ['/ID','/FullName']}},
{snippet: {
maxSnippetChars: 150,
maxMatches: 4,
perMatchTokens: 30
}})
.result()
***_INTEGER
的注意事项:这样做可能会由于将其设置得太小而返回的匹配摘录文本更少,或者通过将其设置得太大而使约束无效。 通常来说,以下查询应返回所需的提取路径和摘要,而不会丢失任何文本:
.where(jsearch.byExample({synopsis: {$word: 'word'}}))
.slice(0, 15)
.map({extract: {paths: ['/ID','/FullName']}}
.result()