简体   繁体   English

如何在Apache Solr中突出显示搜索文本?

[英]How can I highlight the search text in Apache Solr?

I am using Apache Solr for indexing and searching with SolrJ in java/GWT. 我正在使用Apache Solr在Java / GWT中使用SolrJ进行索引和搜索。

When I search for specific word or text then in the result I want to highlight that search text ie the search text is displayed in highlighted manner in the result... help me how can I implement this in my application....if anyone knows any solution... 当我搜索特定的单词或文本时,我想在结果中突出显示该搜索文本,即在结果中以突出显示的方式显示搜索文本...帮助我如何在我的应用程序中实现它。...如果有人知道任何解决方案...

Thanking in advance... 预先感谢...

You can use Solr Highlight for this. 您可以为此使用Solr Highlight By default hightlight component is enabled in solrconfig.xml . 缺省情况下, solrconfig.xml启用了hightlight组件。 You can configure fragmenters inside the highlightComponent section in solrconfig.xml file. 您可以在solrconfig.xml文件的highlightComponent部分内配置碎片程序。

You can also set highlighting parameters inside requestHandler such as : 您还可以在requestHandler内设置突出显示参数,例如:

   <!-- Highlighting defaults -->
   <str name="hl">on</str>
   <str name="hl.fl">text features name</str>
   <str name="f.name.hl.fragsize">0</str>
   <str name="f.name.hl.alternateField">name</str>

Then you can query solr as follows, which will list the highlighted keywords inside tags. 然后,您可以按以下方式查询solr,它将在标签内列出突出显示的关键字。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM