lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Kisselmann <v.kisselm...@googlemail.com>
Subject Custom Query Component: parameters are not appended to query
Date Fri, 17 Feb 2012 18:50:54 GMT
Hello folks,

I build a simple custom component for “hl.q” query.
My case was to inject hl.q=params on the fly,  with filter params like
fields which were in my
standard query.  These were highlighted , because Solr/Lucene have no way of
interpreting an extended "q" clause and saying "this part is a query and
should be highlighted and
this part isn't".
If it works,  the community can have it :)

Facts:  q=roomba AND irobot AND language:de

My component is extended form SearchComponent. I use ResponseBuilder to get
all needed params
like field-names from schema, q-params, etc…



My component  is called as first (it works(debugging,debugQuery)) from my
SearchHandler:
<arr name="first-components">
<str>highlightQuery</str>
 </arr>



Important Clippings from Sourcecode:

public class HighlightQueryComponent extends SearchComponent {

…….
…….

public void process(ResponseBuilder rb) throws IOException {

   if(rb.doHighlights){

List<String> terms = new ArrayList<String>(0);
      SolrQueryRequest req = rb.req;
IndexSchema schema = req.getSchema();
Map<String,SchemaField> fields = schema.getFields();
      SolrParams params = req.getParams();
…..
….
…magic
…
….
Query hlq = new TermQuery(new Term(“text”, hlQuery.toString()));
rb.setHighlightQuery(hlq);   // hlq => text:(roomba AND irobot)



Problem:
In last step my query is adjusted (hlq params from debugging are
“text:(roomba AND irobot)”). It looks fine, the magic in method process()
works.
But nothing happen. If I continue to debug the next components were called,
But my query is the same, without changes.
Either setHighlightQuery doesn´t work, or my params are overridden in
following components.
What can it be?

Best Regards
Vadim

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message