Highlighting and snippets...

310 views
Skip to first unread message

St4rDust

unread,
Mar 3, 2014, 2:48:52 PM3/3/14
to blacklight-...@googlegroups.com
HI,

I'm a noob to BL, whenever I try to turn on HIghling in BL on the field I want highlighted the field is returned empty:

 config.add_index_field 'content', :label => 'content', :highlight => 'true'


this is the "Search requesthandler"

<requestHandler name="search" class="solr.SearchHandler" default="true">
    <!-- default values for query parameters can be specified, these
         will be overridden by parameters in the request
      -->
     <lst name="defaults">
       <str name="defType">dismax</str>
       <str name="echoParams">explicit</str>
    <str name="tie">0.01</str>
       <int name="rows">10</int>

    <str name="qf">
        content^0.5 anchor^1.0 title^1.2</str>
   
    <str name="pf">   

    content^0.5 anchor^1.5 title^1.2 site^1.5 </str>

      
       <str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
   
    <str name="ps">100</str>  
       <str name="hl">true</str>
       <str name="hl.fl">content</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">2</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>
   </requestHandler>

thnx for any help you can give me

Adam Wead

unread,
Mar 3, 2014, 3:06:03 PM3/3/14
to blacklight-...@googlegroups.com
It looks like you need pass the field names to the highlight parameter in solr. You can do this via the CatalogController. Take a look at how I did mine:

https://github.com/awead/catalog/blob/r13/app/controllers/catalog_controller.rb#L10

Basically, you need to tell solr each field you want to highlight, which is the hl.fl parameter. The other two are the tags to wrap the content in.

For example, if I have a solr field called “heading_ssm”, then I pass that field in the hl.fl parameter, then set :highlight => true in the index or show config. NB: there are two solr config sections in the CatalogController, one for the search query which is used for index views, and the second for the document query which is used for show views. I’ve kept my hl.fl values the same for both, but you don’t have to in case you wanted to highlight some fields in the search results but not in the individual results, or vice versa.

hope that helps,

…adam
> --
> You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-develo...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

St4rDust

unread,
Mar 3, 2014, 3:40:28 PM3/3/14
to blacklight-...@googlegroups.com
Do you mean like this in here?

configure_blacklight do |config|
## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
config.default_solr_params = {
:qt => 'search',
:qf => 'id content url title anchor author',
:rows => 10
("hl.fl").to_sym => "content",
("hl.simple.pre").to_sym => '<span class="label label-info">',
("hl.simple.post").to_sym => "</span>",
:hl => true
}

config.default_document_solr_params = {
("hl.fl").to_sym => "content",
("hl.simple.pre").to_sym => '<span class="label label-info">',
("hl.simple.post").to_sym => "</span>",
:hl => true
}

this make BL puke
> To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-development+unsub...@googlegroups.com.

Adam Wead

unread,
Mar 3, 2014, 3:44:28 PM3/3/14
to blacklight-...@googlegroups.com
First thought is, for you have fields like "content url title anchor author” defined in your solr schema.xml file? Can you gist the error messages you are seeing?

…adam
> > To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-develo...@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-develo...@googlegroups.com.

St4rDust

unread,
Mar 3, 2014, 4:08:32 PM3/3/14
to blacklight-...@googlegroups.com
the fileds are in the schema.xml, and display... the "content" field contains whatever the website had and is rather long, it is returned with the search results and I can see it, but when I add : :highlight => 'true' in catalog controller it doesn't render the field anymore, just blank. When I add what you sayd I get:

SyntaxError in SearchHistoryController#index


/home/rrk/enlle/my_app/app/controllers/catalog_controller.rb:13: syntax error, unexpected (, expecting '}' ("hl.fl").to_sym => "content", ^ /home/rrk/enlle/my_app/app/controllers/catalog_controller.rb:13: syntax error, unexpected =>, expecting keyword_end ("hl.fl").to_sym => "content", ^ /home/rrk/enlle/my_app/app/controllers/catalog_controller.rb:13: syntax error, unexpected ',', expecting keyword_end /home/rrk/enlle/my_app/app/controllers/catalog_controller.rb:14: syntax error, unexpected =>, expecting keyword_end ("hl.simple.pre").to_sym => '<span class="label label-info">', ^ /home/rrk/enlle/my_app/app/controllers/catalog_controller.rb:14: syntax error, unexpected ',', expecting keyword_end /home/rrk/enlle/my_app/app/controllers/catalog_controller.rb:15: syntax error, unexpected =>, expecting keyword_end ("hl.simple.post").to_sym => "</span>", ^ /home/rrk/enlle/my_app/app/controllers/catalog_controller.rb:15: syntax error, unexpected ',', expecting keyword_end

> > To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-development+unsub...@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-development+unsub...@googlegroups.com.

Jessie Keck

unread,
Mar 3, 2014, 4:17:08 PM3/3/14
to blacklight-...@googlegroups.com
This is a general ruby syntax error (probably caused my the missing comma after rows).  Also, it may be syntactically OK, but things like ("hl.fl").to_sym => "content" can be written simply as :"hl.fl" => "content"


Also, I'm not exactly sure but I don't think the highlighting will work the way you think it will on the single document view, given the parameters you're trying to pass in as default_document_solr_params.  

- Jessie

To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-develo...@googlegroups.com.

St4rDust

unread,
Mar 3, 2014, 8:46:19 PM3/3/14
to blacklight-...@googlegroups.com
I tried your code, it seems to be working, it looks rather weird, but I guess thats the solrconfig side, i'll mess around with it tomorrow, thnx!

St4rDust

unread,
Mar 5, 2014, 12:20:23 PM3/5/14
to blacklight-...@googlegroups.com

HI,

I got the highlighting to work, but no matter how I change the options in solarconfig.xml, the snippet stays the same size, whihc is aprox. 1 sentence which is a bit short...

Erik Hatcher

unread,
Mar 5, 2014, 1:03:20 PM3/5/14
to blacklight-...@googlegroups.com
What is Solr logging as the request from Blacklight?   What does your solrconfig request handler definition look like now?   Probably just a http://wiki.apache.org/solr/HighlightingParameters#hl.fragsize setting not right or being overridden unintentionally or something?

Erik

On Mar 5, 2014, at 12:20 PM, St4rDust <black...@gmail.com> wrote:


HI,

I got the highlighting to work, but no matter how I change the options in solarconfig.xml, the snippet stays the same size, whihc is aprox. 1 sentence which is a bit short...

--
You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-develo...@googlegroups.com.

St4rDust

unread,
Mar 15, 2014, 3:13:23 AM3/15/14
to blacklight-...@googlegroups.com
Solr request Handler:


<requestHandler name="search" class="solr.SearchHandler" default="true">
    <!-- default values for query parameters can be specified, these
         will be overridden by parameters in the request
      -->
     <lst name="defaults">
       <str name="defType">dismax</str>
       <str name="echoParams">explicit</str>
    <str name="tie">0.01</str>
       <int name="rows">10</int>

    <str name="qf">
        content^0.5 anchor^1.0 title^1.2</str>
   
    <str name="pf">   

    content^0.5 anchor^1.5 title^1.2 site^1.5 </str>

      
       <str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
   
    <str name="ps">100</str>  
       <str name="hl">true</str>
       <str name="hl.fl">content</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.content.hl.snippets">190</str>
       <str name="f.content.hl.fragsize">9000</str>
       <str name="f.content.hl.alternateField">title</str>
       <str name="f.content.hl.maxAlternateFieldLength">1750</str>

   
    </lst>
   </requestHandler>


Am Mittwoch, 5. März 2014 19:03:20 UTC+1 schrieb Ethan Hatcher:
What is Solr logging as the request from Blacklight?   What does your solrconfig request handler definition look like now?   Probably just a http://wiki.apache.org/solr/HighlightingParameters#hl.fragsize setting not right or being overridden unintentionally or something?

Erik
On Mar 5, 2014, at 12:20 PM, St4rDust <black...@gmail.com> wrote:


HI,

I got the highlighting to work, but no matter how I change the options in solarconfig.xml, the snippet stays the same size, whihc is aprox. 1 sentence which is a bit short...

--
You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-development+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages