You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Bram Vereertbrugghen (JIRA)" <ji...@apache.org> on 2018/03/19 13:56:00 UTC

[jira] [Comment Edited] (SOLR-4722) Highlighter which generates a list of query term position(s) for each item in a list of documents, or returns null if highlighting is disabled.

    [ https://issues.apache.org/jira/browse/SOLR-4722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16404826#comment-16404826 ] 

Bram Vereertbrugghen edited comment on SOLR-4722 at 3/19/18 1:55 PM:
---------------------------------------------------------------------

As a response to [~TamerBoz]:

What I did was the following:
 1. place the solr-positionshighlighter.jar into /opt/solr/server/solr/lib, where Solr could find it. (Note: I'm running Solr in a docker container, so our paths will be different).

Then in mycore/conf/solrconfig.xml:

2. Create the searchComponent using the above snippets and name it 'highlighter' (I didn't want to deal with duplicate naming or overwritten issues, so I played it safe).
{code:java}
 <searchComponent class="solr.HighlightComponent" name="highlighter">
    <highlighting class="org.apache.solr.highlight.PositionsSolrHighlighter"/>
 </searchComponent>{code}
3. Either create a new requestHandler for testing, or append it to an existing one using <arr>...</arr>. This is a new endpoint where the highlighting will be the new highlighter:
{code:java}
  <requestHandler name="/test-point" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="omitHeader">true</str>
      <str name="wt">json</str>
      <str name="indent">true</str>
    </lst>
    <arr name="last-components">
      <str>highlighter</str>
    </arr>
  </requestHandler>
{code}
4. Make the following call (change the url so it points to your core and solr instance):
{noformat}
http://localhost:8002/solr/mycore/test-point?hl.fl=tm_field_test&hl=on&indent=on&q=tm_field_test:test&wt=json{noformat}
This will output a highlighting array containing a number, and this number contains the position of the word in the document.
NOTE: I found very strange results when using this .jar on documents where the values were arrays. If this is your case, be prepared to rewrite some stuff (or find the correct interpretation of the results).

 

 


was (Author: darm):
As a response to [~TamerBoz]:

What I did was the following:
1. place the solr-positionshighlighter.jar into /opt/solr/server/solr/lib, where Solr could find it. (Note: I'm running Solr in a docker container, so our paths will be different).
2. Create the searchComponent using the above snippets and name it 'highlighter' (so I could be able to outrule duplicate naming issues).
{code:java}
 <searchComponent class="solr.HighlightComponent" name="highlighter">
    <highlighting class="org.apache.solr.highlight.PositionsSolrHighlighter"/>
 </searchComponent>{code}
3. Create a new requestHandler explicitly using this way of highlighting.
{code:java}
  <requestHandler name="/test-point" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="omitHeader">true</str>
      <str name="wt">json</str>
      <str name="indent">true</str>
    </lst>
    <arr name="last-components">
      <str>highlighter</str>
    </arr>
  </requestHandler>
{code}
4. Make the followinhg call:
{noformat}
http://localhost:8002/solr/mycore/test-point?hl.fl=tm_field_test&hl=on&indent=on&q=tm_field_test:test&wt=json{noformat}
This makes the call

 

 

> Highlighter which generates a list of query term position(s) for each item in a list of documents, or returns null if highlighting is disabled.
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SOLR-4722
>                 URL: https://issues.apache.org/jira/browse/SOLR-4722
>             Project: Solr
>          Issue Type: New Feature
>          Components: highlighter
>    Affects Versions: 4.3, 6.0
>            Reporter: Tricia Jenkins
>            Priority: Minor
>         Attachments: PositionsSolrHighlighter.java, SOLR-4722.patch, SOLR-4722.patch, solr-positionshighlighter.jar
>
>
> As an alternative to returning snippets, this highlighter provides the (term) position for query matches.  One usecase for this is to reconcile the term position from the Solr index with 'word' coordinates provided by an OCR process.  In this way we are able to 'highlight' an image, like a page from a book or an article from a newspaper, in the locations that match the user's query.
> This is based on the FastVectorHighlighter and requires that termVectors, termOffsets and termPositions be stored.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org