You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by PAVAN <pa...@gmail.com> on 2013/09/25 15:12:05 UTC
AND/OR logic
Hi,
I have situation that if user enters any string to search then i need
to display the results in the following way.
1. It has to match exact string what he entered.
(or)
2. It has to split the string and search for individual keywords(for every
string) and it has to display the results.
Ex : suppose user searching for
"royal enfeild bikes"
First Condition----it has to check for whole string "royal enfiled bikes"
Second Condition ----- it has to display the results like royal OR enfiled
OR bikes
Can anyone give me suggestions.
--
View this message in context: http://lucene.472066.n3.nabble.com/AND-OR-logic-tp4091931.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: AND/OR logic
Posted by PAVAN <pa...@gmail.com>.
Hi Jack,
Thank you for giving reply
I am doing my configuration in the following way. Can you please check
it and give some suggestion if i need any changes based on my requirement.
i am storing the query string in the following way.
If q="a b c d e f"
s=a+b+c+d+e+f
s1=a+b+c+d+e
s2=f
<arr name="components">
<str>query</str>
<str>debug</str>
</arr>
<lst name="defaults">
<str name="c"></str>
<str name="s"></str>
<str name="s1"></str>
<str name="s2"></str>
<str name="fl">*,score</str>
<str name="debugQuery">false</str>
<str name="echoParams">all</str>
<bool name="omitHeader">true</bool>
</lst>
<lst name="invariants">
<int name="count">3</int>
<str name="wt">json</str>
<str name="1.q.op">AND</str>
<str name="1.df">fsw_title</str>
<str name="1.rows">14</str>
<str name="1.q">{!edismax v=$s}</str>
<str name="1.sort">mpId desc</str>
<str name="1.fq">city:All OR _query_:"{!field f=city v=$c}"</str>
<bool name="1.group">true</bool>
<str name="1.group.field">mpId</str>
<str name="1.group.limit">4</str>
<bool name="1.group.main">true</bool>
<str name="1.group.sort">score desc</str>
<str name="1.defType">edismax</str>
<bool name="1.lowercaseOperators">false</bool>
<str name="1.qf">tsw_title^15.0 tf_title^10.0 tsw_keywords^1
keywords^0.5</str>
<str name="1.pf2">fsw_title~1^50.0</str>
<str name="1.pf3">fsw_title~1^25.0</str>
<str name="1.bf">sum(product(typeId,100),weightage)</str>
<str name="2.q.op">OR</str>
<str name="2.df">fsw_title</str>
<str name="2.rows">14</str>
<str name="2.q">_query_:"{!edismax qf=$qfs1 pf=$pfx pf2=$pf2x v=$s1}" AND
_query_:"{!edismax qf=$qfs2 v=$s2}"</str>
<str name="2.sort">mpId desc, score desc</str>
<str name="2.fq">city:All OR _query_:"{!field f=city v=$c}"</str>
<bool name="2.group">true</bool>
<str name="2.group.field">mpId</str>
<str name="2.group.limit">4</str>
<bool name="2.group.main">true</bool>
<str name="2.group.sort">score desc</str>
<bool name="2.lowercaseOperators">false</bool>
<str name="2.qfs1">fsw_title^30 tsw_title^20 tf_title^15.0
keywords^1.0</str>
<str name="2.qfs2">tsw_title^15.0 tf_title^10.0 tsw_keywords^1
keywords^0.5</str>
<str name="2.pfx">fsw_title~1^100.0</str>
<str name="2.pf2x">fsw_title~1^50.0</str>
<str name="2.pf3x">fsw_title~1^25.0</str>
<str name="2.bf">product(typeId,100)</str>
</lst>
</requestHandler>
--
View this message in context: http://lucene.472066.n3.nabble.com/AND-OR-logic-tp4091931p4092059.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: AND/OR logic
Posted by Jack Krupansky <ja...@basetechnology.com>.
Is your requirement specifying that none of the alternative results should
be shown if there are any primary results, or that the primary results
should be shown first, or that both are acceptable?
You could do a phrase query for the full list of terms, and then do a second
query with OR if the first returns no results.
Or, you could use a boost on the phrase and OR it with a de-boosted
parenthesized OR query of the individual terms to show both but with the
phrase matches first. If the natural scoring doesn't already boost the
phrases enough by default.
You could also do that second approach by simply using the edismax query
parser with the pf parameter to boost the phrase of all terms.
-- Jack Krupansky
-----Original Message-----
From: PAVAN
Sent: Wednesday, September 25, 2013 9:12 AM
To: solr-user@lucene.apache.org
Subject: AND/OR logic
Hi,
I have situation that if user enters any string to search then i need
to display the results in the following way.
1. It has to match exact string what he entered.
(or)
2. It has to split the string and search for individual keywords(for every
string) and it has to display the results.
Ex : suppose user searching for
"royal enfeild bikes"
First Condition----it has to check for whole string "royal enfiled bikes"
Second Condition ----- it has to display the results like royal OR enfiled
OR bikes
Can anyone give me suggestions.
--
View this message in context:
http://lucene.472066.n3.nabble.com/AND-OR-logic-tp4091931.html
Sent from the Solr - User mailing list archive at Nabble.com.