突出显示整个查询短语
我使用 solr 进行搜索,并为搜索结果实现了突出显示功能。 当我的搜索字符串是ring
时,它会突出显示ring
,但是当搜索字符串是“金戒指”
时,它也只会突出显示gold< /code>,我想突出显示整个
金戒指
为了突出显示,我使用了我得到的描述字段,
highlighting ={
"8252": {
"text": [
" and <em>gold</em><em>Ring</em> design was finely crafted in Japan."
]
},
"8142": {
"text": [
"This <em>elegant</em> <em>Ring</em> has an Akoya cultured pearl with a band of bezel-set round diamonds making"
]
}
};
现在我将其解析为
$.each(newresult.response.docs, function(i,item){
var word = highlight[item["UID_PK"]];
var result="";
var j=0;
for (j=0 ;j<=item.text.length;j++)
{
result = result+item.text[j]+"<br>";
}
result=result.replace(word,'<em>' + word + '</em>');
});
现在我应该如何解析,以便我突出显示金戒指
i am using solr for search and i implemented highlighting feature for my search results.
when i my search string is ring
it highlight ring
but when search string is "gold ring"
than also it highlight only gold
, where i wanted to highlight whole gold ring
for highlighting i use description field which i got as
highlighting ={
"8252": {
"text": [
" and <em>gold</em><em>Ring</em> design was finely crafted in Japan."
]
},
"8142": {
"text": [
"This <em>elegant</em> <em>Ring</em> has an Akoya cultured pearl with a band of bezel-set round diamonds making"
]
}
};
Now i am parsing it as
$.each(newresult.response.docs, function(i,item){
var word = highlight[item["UID_PK"]];
var result="";
var j=0;
for (j=0 ;j<=item.text.length;j++)
{
result = result+item.text[j]+"<br>";
}
result=result.replace(word,'<em>' + word + '</em>');
});
Now how should i parse so that i got gold ring
highlighted
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否传入了 -
查询参数?该值告诉 solr 高亮显示多项。该参数的值默认设置为
false
。因此,您需要通过使用查询参数传递它来使其true
。如需更多参考,请访问 Solr 文档。
Have you passed -
in query parameters? This value tells solr to highlight multi term. Value of this parameter is by default set to
false
. So, you need to make ittrue
by passing it with query parameter.For more reference please visit Solr Documentation.