0
votes

I am trying to highlight particular field as per the result from Solr. But I am not able to understand whether I am getting the results in the proper format. Below are my changes in solrconfig.xml

  <lst name="defaults">
          <str name="echoParams">explicit</str>
          <int name="rows">10</int>
       <str name="hl">on</str>
       <str name="hl.fl">content features title name</str>
       <str name="hl.encoder">html</str>
       <str name="hl.simple.pre">&lt;b&gt;</str>
       <str name="hl.simple.post">&lt;/b&gt;</str>
       <str name="f.title.hl.fragsize">0</str>
       <str name="f.title.hl.alternateField">title</str>
       <str name="f.name.hl.fragsize">0</str>
       <str name="f.name.hl.alternateField">name</str>
       <str name="f.content.hl.snippets">3</str>
       <str name="f.content.hl.fragsize">200</str>
       <str name="f.content.hl.alternateField">content</str>
       <str name="f.content.hl.maxAlternateFieldLength">750</str>
    </lst>

I run the query using the following url and the results are shown as below. What am I doing wrong? How do I highlight the text using the below result. I know Ajay is found in id=1. How do I get the other results to highlight them. URL: http://localhost:8983/solr/test/query?q=Ajay&hl=true&hl.fl=name

{
  "responseHeader":{
    "status":0,
    "QTime":2,
    "params":{
      "q":"Ajay",
      "hl.fl":"name",
      "hl":"true"}},
  "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"1",
        "name_s":"Ajay",
        "_version_":1507026478114537472}]
  },
  "highlighting":{
    "1":{}}}
1

1 Answers

0
votes

Here hl.fl should be the field which needs to be highlighted.Remember this field needs to be indexed too.