无法获得突出显示的Solr响应(Cannot get highlighted Solr response)

编程入门 行业动态 更新时间:2024-10-18 03:32:18
无法获得突出显示的Solr响应(Cannot get highlighted Solr response)

我正在使用Solr示例服务器进行调查。 提供所有缓存文件后,主要是HTML文件,除了高亮部分外,它工作正常。

我正在使用的请求网址如下,

http://localhost:8983/solr/collection1/select?q=keyword&wt=xml&hl=true

XML响应如下,

<response> <lst name="responseHeader">...</lst> <result name="response" numFound="371" start="0"> <doc> <arr name="links"> <str>rect</str> <str>FJU_KDJFJJ_DJ_13</str> </arr> <str name="id"> F:\SkyDrive\funproj\cache\adfadf\asdff.htm </str> <arr name="title"> <str>asdff.htm</str> </arr> <arr name="content_type"> <str>text/html; charset=ISO-8859-1</str> </arr> <str name="resourcename"> F:\SkyDrive\funproj\cache\adfadf\asdff.htm </str> <arr name="content"> <str>...</str> </arr> <long name="_version_">1418589758873927680</long> </doc> <doc>...</doc> </result> <lst name="highlighting"> <lst name="F:\SkyDrive\funproj\cache\adfadf\asdff.htm"/> <lst name="F:\SkyDrive\funproj\cache\cvzcv\c58053e10vq.htm"/> <lst name="F:\SkyDrive\funproj\cache\hgdfhdfgh\c00302e10vq.htm"/> <lst name="F:\SkyDrive\funproj\cache\asdfasdf\c00945e10vq.htm"/> <lst name="F:\SkyDrive\funproj\cache\hjmyukt\asfdf06113002_03312010.htm"/> <lst name="F:\SkyDrive\funproj\cache\nmvbmnm\saf0q033111.htm"/> <lst name="F:\SkyDrive\funproj\cache\lkiullkl\a10-5974_110q.htm"/> <lst name="F:\SkyDrive\funproj\cache\jhlhjkl\fdfinal.htm"/> <lst name="F:\SkyDrive\funproj\cache\vcbxcbvcx\zynex10q33110_5132010.htm"/> <lst name="F:\SkyDrive\funproj\cache\yuiuiou\v185403_10q.htm"/> </lst> </response>

无论JSON还是XML,响应都没有突出部分。 我检查了本地文件系统和示例服务器的管理页面中的solrconfig.xml。 突出显示默认打开,前/后设置为“ ”/“ ”。 示例搜索门户本身在其结果中突出显示的情况下正常工作。 但由于它不是AJAX,因此我无法通过Chrome查看其结果。

我做错了什么?

I'm using Solr example server to do an investigation. After fed it with all cached documents, mostly html files, it works fine except the highlight part.

The request URL I'm using is as followed,

http://localhost:8983/solr/collection1/select?q=keyword&wt=xml&hl=true

And the XML response is as followed,

<response> <lst name="responseHeader">...</lst> <result name="response" numFound="371" start="0"> <doc> <arr name="links"> <str>rect</str> <str>FJU_KDJFJJ_DJ_13</str> </arr> <str name="id"> F:\SkyDrive\funproj\cache\adfadf\asdff.htm </str> <arr name="title"> <str>asdff.htm</str> </arr> <arr name="content_type"> <str>text/html; charset=ISO-8859-1</str> </arr> <str name="resourcename"> F:\SkyDrive\funproj\cache\adfadf\asdff.htm </str> <arr name="content"> <str>...</str> </arr> <long name="_version_">1418589758873927680</long> </doc> <doc>...</doc> </result> <lst name="highlighting"> <lst name="F:\SkyDrive\funproj\cache\adfadf\asdff.htm"/> <lst name="F:\SkyDrive\funproj\cache\cvzcv\c58053e10vq.htm"/> <lst name="F:\SkyDrive\funproj\cache\hgdfhdfgh\c00302e10vq.htm"/> <lst name="F:\SkyDrive\funproj\cache\asdfasdf\c00945e10vq.htm"/> <lst name="F:\SkyDrive\funproj\cache\hjmyukt\asfdf06113002_03312010.htm"/> <lst name="F:\SkyDrive\funproj\cache\nmvbmnm\saf0q033111.htm"/> <lst name="F:\SkyDrive\funproj\cache\lkiullkl\a10-5974_110q.htm"/> <lst name="F:\SkyDrive\funproj\cache\jhlhjkl\fdfinal.htm"/> <lst name="F:\SkyDrive\funproj\cache\vcbxcbvcx\zynex10q33110_5132010.htm"/> <lst name="F:\SkyDrive\funproj\cache\yuiuiou\v185403_10q.htm"/> </lst> </response>

The response, no matter JSON or XML, does not have the highlight part at all. I've checked the solrconfig.xml both in local file system and the admin page of the example server. The Highlighting is default on and pre/post are set to ""/"". The example search portal itself works fine with highlight in its results. But since it's not AJAX, there's no way for me to check its result through chrome.

What did I do wrong?

最满意答案

您必须使用hl.fl来定义需要突出显示的字段。 例如,如果您想在content字段中搜索并突出显示匹配,则可以使用下面的查询:

http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content

默认情况下,突出显示响应只会返回一个片段,即使您的字段有多个匹配。 此外,片段的长度(fragsize)默认设置为100个字符。

您可以使用hl.snippets和hl.fragsize来修改它们。

例如,要修改碎片大小

http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content&hl.fragsize=5000

传递hl.fragsize=0会使fragsize无限制。

为了改变片段的数量:

http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content&hl.snippets=10

请参阅solr wiki获取更多参数。

You have to define the fields using hl.fl which needs to be highlighted. For example, if you want to search and highlight hits in content field, you can use query below:

http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content

By default highlighting response returns only one snippet,even if your field have multiple hits. Also the length of snippet(fragsize) is set to 100 chars by default.

You can use hl.snippets and hl.fragsize to modify them.

For example, to modify fragsize:

http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content&hl.fragsize=5000

Passing hl.fragsize=0 will make fragsize unlimited.

For changing number of snippets:

http://localhost:8983/solr/collection1/select?q=content:keyword&wt=xml&hl=true&hl.q=content:keyword&hl.fl=content&hl.snippets=10

Refer to solr wiki for more parameters.

更多推荐

本文发布于:2023-07-22 09:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219093.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Solr   highlighted   response

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!