我正在使用Solr4.7在我的服务器上启用标准高亮显示。我的文件(除其他外)包括下列字段:
{
"id": [
"fdc3833a-0e4f-4314-ba8c"
],,
"tag": [
"solr",
"solrJ",
"solrCloud"
"solrX"
],
"title": "Solr question about highlighting",
"description": "I am working to enable Standard Highlighting on my server with Solr 4.7. My documents contain (among the others) the following.........",
}在这三个字段中,只有“标记”是多值的。我在solrconfig.xml文件中的默认配置是:
<str name="hl">on</str>
<str name="hl.fl">content title description tag</str>
<str name="hl.snippets">2</str>当我运行这样的查询时:
https://<YOUR_PATH>/select?q=solr*&wt=json&indent=true我有以下要点:
"highlighting": {
"fdc3833a-0e4f-4314-ba8c": {
"title": [
"<b>Solr</b> question about highlighting"
],
"summary": [
"I am working to enable Standard Highlighting on my server with <b>Solr</b> 4.7. My documents contain (among the others) the following........."
],
**"tag": [
"<b>Solr</b>",
"<b>SolrJ</b>"
]**
}
}而我希望得到所有的标签。我发现Solr在多值字段中处理多个值,就像它们被高亮显示一样,因此由于我有hl.snippets=2,所以只显示前两个值。如何获得标记的所有值?(显然,仅为多值字段更改代码段的数量是不可接受的答案)。在Solr 4.7中是否有一种在突出显示中处理多值字段的方法?
我的期望是得到这样的回应:
"highlighting": {
"fdc3833a-0e4f-4314-ba8c": {
"title": [
"<b>Solr</b> question about highlighting"
],
"summary": [
"I am working to enable Standard Highlighting on my server with <b>Solr</b> 4.7. My documents contain (among the others) the following........."
],
**"tag": [
"<b>Solr</b>",
"<b>SolrJ</b>",
"<b>SolrCloud</b>",
"<b>SolrX</b>"
]**
}
}发布于 2016-07-07 12:31:07
在搜索文档并运行一些测试之后,我发现在solrconfig.xml中设置参数solrconfig.xml:
<str name="hl.preserveMulti">true</str>它不仅像文档所说的那样保留multiValue文档中值的顺序,而且还按其原始顺序返回多值文档的所有值。因此,如果我们设置上述参数,并且索引中有以下文档:
{
"id": [
"fdc3833a-0e4f-4314-ba8c"
],,
"tag": [
"solr",
"solrJ",
"solrCloud"
"solrX",
"notRelevantTag"
],
"title": "Solr question about highlighting",
"description": "I am working to enable Standard Highlighting on my server with Solr 4.7. My documents contain (among the others) the following.........",
}查询:
https://<YOUR_PATH>/select?q=solr*&wt=json&indent=true将给我一个突出的结果如下:
"highlighting": {
"fdc3833a-0e4f-4314-ba8c": {
"title": [
"<b>Solr</b> question about highlighting"
],
"summary": [
"I am working to enable Standard Highlighting on my server with <b>Solr</b> 4.7. My documents contain (among the others) the following........."
],
**"tag": [
"<b>Solr</b>",
"<b>SolrJ</b>",
"<b>SolrCloud</b>",
"<b>SolrX</b>",
"notRelevantTag"
]**
}
}https://stackoverflow.com/questions/38245547
复制相似问题