: Is there a way to construct a query that needs two different parsers?
: Example:
: q={!xmlparser}<SpanFirst  fieldName="text_en" end="5"  
boost="1.2"><SpanTerm>Hello</SpanTerm></SpanFirst>
: AND
: q={!edismax}text_en:"foo bar"~4

The easies way to do what you're asking about would be to choose one of 
those queries for "storking" purposes, and put the other one in an "fq" 
simply for filtering.

But you can build a single compelx query using multiple parsers by 
leveraging the "lucene" parser's support for nesting queries -- ie: in a 
larger boolean query -- and then use local param variables to reference 
your other param names...


q=({!edismax qf=text_en v=$my_main_query} OR {!xmlparser v=$my_span_query})
my_main_query="foo bar"~4
my_span_query=<SpanFirst  fieldName="text_en" 
end="5"boost="1.2"><SpanTerm>Hello</SpanTerm></SpanFirst>

...the important bits that tend to trip people up is to make sure you 
don't start your query string with the local param syntax of another 
parser, and that you don't pass the input of your nested parsers "inline" 
if they contain white space .. hence the parens above and the use of the 
'v' local param.

If you tried to do the same thing like either of these queries below, it 
wouldn't work because it would confuse the parsing logic...

bad_q1={!edismax qf=text_en v=$my_main_query} OR {!xmlparser v=$my_span_query}

bad_q2=({!edismax qf=text_en}"foo bar"~4 OR {!xmlparser v=$my_span_query})

in "bad_q1" solr would think you wanted the *entire* param value 
(including the "OR {!xmlparser..." passed to the "edismax" parsers

in "bad_q2" the nested edismax parser would only be given the input '"foo" 
.. and not the ' bar"~4' bit, because the outer most (implicit) lucene 
parser doens't understand how much of the input you intended for the 
nested parser.


-Hoss
http://www.lucidworks.com/

Reply via email to