Hi,
I'm using DisMaxRequestHandler and trying to transform a user-entered
multi-term boolean query (e.g. foo bar baz).
I've configured DisMaxRH like so:
<str name="qf">
name^1.2 <-- I removed the manu field from here -->
</str>
<str name="pf">
manu^1.4
</str>
<int name="ps">0</int> <-- try to require exact phrases -->
This gets my foo bar baz query rewritten to:
+(((name:foo^1.2)~0.01 (name:bar^1.2)~0.01 (name:baz^1.2)~0.01)~2) (manu:"foo
bar baz"^1.4)~0.01
That's nice, but the problem here is that the manu:"foo bar baz" part here is
optional (Occur.SHOULD). What I'm like to do is have it required (Occur.MUST),
and combine it with the first part of the query with an OR.
Something like this:
+((((name:foo^1.2)~0.01 (name:bar^1.2)~0.01 (name:baz^1.2)~0.01) | ((manu:”foo
bar baz”)~0.01))~2)
I modified DisMaxRequestHandler to make the phrase part of the query required,
but that only got me this:
+(((name:foo^1.2)~0.01 (name:bar^1.2)~0.01 (name:baz^1.2)~0.01)~2) +(manu:"foo
bar baz"^1.4)~0.01
... and this is not quite what I want -- it is missing an OR before
"_(manu:...." part.
Either my brain is frozen or it's impossible to get the above combination with
OR ( that | ) between clauses.
Questions:
- Can DisMaxRH get me the above query just through its configuration in
solrconfig.xml?
- Can anyone see how DisMaxRH can be modified to product the above REQUIRED OR
REQUIRED type query?
- Does anyone else see a need for this?
My use case is this:
Think of the "name" field as less-important metadata field and "manu" as the
more important and longer content field. When a person enters foo bar baz, I
want to avoid matches in the manu/content field caused by matches of individual
terms (that is why I removed manu field from the "qf" DisMax param) -- I want
a match in the manu/content field only if the exact phrase appears there (that
is why I am using "pf" and "ps" of zero).
My goal is not to increase the relevance of docs with exact phrase matches, my
goal is to completely avoid matches on individual terms in the manu field.
Thanks,
Otis
--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch