3
我在algoliasearch-client-js中找不到这两个设置之间的差异。 你能否简单地解释一下,更重要的是为什么要使用这些设置?algolia搜索 - 用于突出显示vs属性的属性片段
例子太棒了!
我在algoliasearch-client-js中找不到这两个设置之间的差异。 你能否简单地解释一下,更重要的是为什么要使用这些设置?algolia搜索 - 用于突出显示vs属性的属性片段
例子太棒了!
attributesToHighlight
允许检索使用<em>
html标记突出显示的匹配单词的完整内容属性。
attributesToSnippet
提取包含最匹配单词的属性部分并突出显示它们。
例如,如果您索引对象是:
{ "question": "algolia search - attributes to highlight vs attributes to snippet"}
如果使用attributesToHighlight
,你的搜索将类似于:
search("algolia se", {"attributesToHighlight": "question"})
,您会收到这种形式的答案:
{
"question": "algolia search - attributes to high:light vs attributes to snippet",
"_highlightResult": {
"question": {
"value": "<em>algolia</em> </em>se</em>arch - attributes to highlight vs attributes to snippet",
"matchLevel": "full",
"matchedWords": [
"algolia",
"se"
]
}
如果您使用attributesToSnippet
,您的搜索将类似于:
search("algolia se", {"attributesToSnippet": "question:2"})
,您会收到这种形式的答案:
{
"question": "algolia search - attributes to high:light vs attributes to snippet",
"_snippetResult": {
"question": {
"value": "<em>algolia</em> </em>se</em>arch",
"matchLevel": "full",
"matchedWords": [
"algolia",
"se"
]
}
这是伟大的!非常感谢你的解释 – vergilius