You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Bent Jensen <be...@yahoo.com> on 2011/12/13 02:03:53 UTC

highlighting questions


I am trying to figure out how to display search query fields highlighted in html. I can enable the highlighting in the query, and I think I get the correct response back (See below: I search using 'Contents' and the highlighting is shown with <strong> and </strong>. However, I can't figure out what to add to the xslt file to display in html. I think it is a question of defining the appropriate xpath(?), but I am stuck. Can someone point me in the right direction? Thanks in advance!


Here is the result I get back:
<?xml version="1.0" encoding="UTF-8" ?> 
- <response>
- <lstname="responseHeader">
  <intname="status">0</int> 
  <intname="QTime">20</int> 
- <lstname="params">
  <str name="explainOther"/> 
  <strname="indent">on</str> 
  <strname="hl.simple.pre">'<strong>'</str> 
  <strname="hl.fl">*</str> 
  <str name="wt"/> 
  <strname="hl">on</str> 
  <strname="rows">10</str> 
  <strname="version">2.2</str> 
  <str name="fl"/> 
  <strname="start">0</str> 
  <strname="q">contents</str> 
  <strname="hl.simple.post">'</strong>'</str> 
  <str name="qt"/> 
  <str name="fq"/> 
  </lst>
  </lst>
- <resultname="response"numFound="1"start="0">
- <doc>
- <arrname="content">
  <str>Start with the Table of Contents. See if you can find the topic that you are interested in. Look through the section to see if there is a resource that can help you. If you find one, you may want to attach a Post-it tab so you can find the page later. Write down all of the information that you need to find out more information about the resource: agency name, name of contact person, telephone number, email and website addresses. If you were unable to find a resource that will help you in this resource guide, a good first step would be to call your local Independent Living Center. They will have a good idea of what is available in your area. A second step would be to call or email us at the Rehabilitation Research Center. We have a ROBOT resource specialist who may be able to assist. You can reach Lois Roberts, the “Back On Track …To Success” Mentoring Program Assistant, at 408-793-6426 or email her at Lois.Roberts@hhs.sccgov.org</str> 
  </arr>
- <arrname="doclink">
  <str>robot.pdf#page=11</str> 
  </arr>
  <strname="heading1">CHAPTER 1: How to Use This Resource Guide</str> 
  <strname="id">1-1</str> 
  </doc>
  </result>
- <lstname="highlighting">
- <lstname="1-1">
- <arrname="content">
  <str>Start with the Table of '<strong>'Contents'</strong>'. See if you can find the topic that you are interested in. Look</str> 
  </arr>
  </lst>
  </lst>
  </response>

Re: highlighting questions

Posted by Erick Erickson <er...@gmail.com>.
How to get *what* to display in HTML? The VelocityResponseWriter?
Extracting this content to show in your webapp? How are you displaying
any page at all? You can look at the examples in the VelocityResponseWriter
to get an idea of how to do this with that templating engine.....

But the general idea here is that whatever parses your response has to
match the <id> field in the <doc> tag with the proper element from
the <lstname="highlighting"> element and mix-n-match them.

Hope that helps
Erick

On Mon, Dec 12, 2011 at 8:03 PM, Bent Jensen <be...@yahoo.com> wrote:
>
>
> I am trying to figure out how to display search query fields highlighted in html. I can enable the highlighting in the query, and I think I get the correct response back (See below: I search using 'Contents' and the highlighting is shown with <strong> and </strong>. However, I can't figure out what to add to the xslt file to display in html. I think it is a question of defining the appropriate xpath(?), but I am stuck. Can someone point me in the right direction? Thanks in advance!
>
>
> Here is the result I get back:
> <?xml version="1.0" encoding="UTF-8" ?>
> - <response>
> - <lstname="responseHeader">
>   <intname="status">0</int>
>   <intname="QTime">20</int>
> - <lstname="params">
>   <str name="explainOther"/>
>   <strname="indent">on</str>
>   <strname="hl.simple.pre">'<strong>'</str>
>   <strname="hl.fl">*</str>
>   <str name="wt"/>
>   <strname="hl">on</str>
>   <strname="rows">10</str>
>   <strname="version">2.2</str>
>   <str name="fl"/>
>   <strname="start">0</str>
>   <strname="q">contents</str>
>   <strname="hl.simple.post">'</strong>'</str>
>   <str name="qt"/>
>   <str name="fq"/>
>   </lst>
>   </lst>
> - <resultname="response"numFound="1"start="0">
> - <doc>
> - <arrname="content">
>   <str>Start with the Table of Contents. See if you can find the topic that you are interested in. Look through the section to see if there is a resource that can help you. If you find one, you may want to attach a Post-it tab so you can find the page later. Write down all of the information that you need to find out more information about the resource: agency name, name of contact person, telephone number, email and website addresses. If you were unable to find a resource that will help you in this resource guide, a good first step would be to call your local Independent Living Center. They will have a good idea of what is available in your area. A second step would be to call or email us at the Rehabilitation Research Center. We have a ROBOT resource specialist who may be able to assist. You can reach Lois Roberts, the “Back On Track …To Success” Mentoring Program Assistant, at 408-793-6426 or email her at Lois.Roberts@hhs.sccgov.org</str>
>   </arr>
> - <arrname="doclink">
>   <str>robot.pdf#page=11</str>
>   </arr>
>   <strname="heading1">CHAPTER 1: How to Use This Resource Guide</str>
>   <strname="id">1-1</str>
>   </doc>
>   </result>
> - <lstname="highlighting">
> - <lstname="1-1">
> - <arrname="content">
>   <str>Start with the Table of '<strong>'Contents'</strong>'. See if you can find the topic that you are interested in. Look</str>
>   </arr>
>   </lst>
>   </lst>
>   </response>