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 Tushar Arora <ta...@gmail.com> on 2020/07/02 05:22:10 UTC

How to use two search string in a single solr query

Hi,
I have a scenario with following entry in the request handler(handler1) of
solrconfig.xml.(defType=edismax is used)
<str name="qf">description</str> <str name="qf">category</str> <str name=
"qf">title^4</str> <str name="qf">demand^0.3</str>
<str name="mm">2&lt;-1 4&lt;-30%</str>

When I searched 'bags' as a search string, solr returned 15000 results.
Query Used :
http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=bags&qt=handler1&rows=10&wt=json

And when searched 'books' as a search string, solr returns say 3348 results.
Query Used :
http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=books&qt=handler1&rows=10&wt=json

I want to use both 'bags' and 'books' as a search string in a single query.
I used the following query:
http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=%22bags%22+OR+%22books%22&qt=handler1&rows=10&wt=json
But OR operator not working. It will only give 7 results.


I even tried this :
http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=(bags)+OR+(books)&qt=handler1&rows=10&wt=json
But it also gives 7 results.

But my concern is to include the result of both 'bags' OR 'books' in a
single query.
Is there any way to use two search strings in a single query?

Re: How to use two search string in a single solr query

Posted by Tushar Arora <ta...@gmail.com>.
Hi
Thanks Erick and Walter for your response.

Solr Version Used : 6.5.0
I tried to elaborate the issue:

Case 1 : Search String : Industrial Electric Oven
              Results=945
Case 2 : Search String : Dell laptop bags
              Results=992

In above both cases, mm play its role.(match any 2 words out of 3)

Now, I want to search with both string and mm still playing its role.

q=(Industrial Electric Oven) OR (Dell laptop bags)
I want mm still play its role in matching two out of three words in both
the cases.
Ex: Documents containing electric oven, industrial oven, dell bags, laptop
bags should be returned.
     I don't want the documents containing only dell, bags,etc. Also no
document containing electric bags.

Regards,
Tushar Arora


On Thu, 2 Jul 2020 at 22:37, Walter Underwood <wu...@wunderwood.org> wrote:

> First, remove the “mm” parameter from the request handler definition. That
> can
> be added back in and tweaked later, or just left out.
>
> Second, you don’t need any query syntax to search for two words. This
> query
> should work fine:
>
>   books bags
>
> wunder
> Walter Underwood
> wunder@wunderwood.org
> http://observer.wunderwood.org/  (my blog)
>
> > On Jul 1, 2020, at 10:22 PM, Tushar Arora <ta...@gmail.com> wrote:
> >
> > Hi,
> > I have a scenario with following entry in the request handler(handler1)
> of
> > solrconfig.xml.(defType=edismax is used)
> > <str name="qf">description</str> <str name="qf">category</str> <str name=
> > "qf">title^4</str> <str name="qf">demand^0.3</str>
> > <str name="mm">2&lt;-1 4&lt;-30%</str>
> >
> > When I searched 'bags' as a search string, solr returned 15000 results.
> > Query Used :
> >
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=bags&qt=handler1&rows=10&wt=json
> >
> > And when searched 'books' as a search string, solr returns say 3348
> results.
> > Query Used :
> >
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=books&qt=handler1&rows=10&wt=json
> >
> > I want to use both 'bags' and 'books' as a search string in a single
> query.
> > I used the following query:
> >
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=%22bags%22+OR+%22books%22&qt=handler1&rows=10&wt=json
> > But OR operator not working. It will only give 7 results.
> >
> >
> > I even tried this :
> >
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=(bags)+OR+(books)&qt=handler1&rows=10&wt=json
> > But it also gives 7 results.
> >
> > But my concern is to include the result of both 'bags' OR 'books' in a
> > single query.
> > Is there any way to use two search strings in a single query?
>
>

Re: How to use two search string in a single solr query

Posted by Walter Underwood <wu...@wunderwood.org>.
First, remove the “mm” parameter from the request handler definition. That can 
be added back in and tweaked later, or just left out.

Second, you don’t need any query syntax to search for two words. This query 
should work fine:

  books bags

wunder
Walter Underwood
wunder@wunderwood.org
http://observer.wunderwood.org/  (my blog)

> On Jul 1, 2020, at 10:22 PM, Tushar Arora <ta...@gmail.com> wrote:
> 
> Hi,
> I have a scenario with following entry in the request handler(handler1) of
> solrconfig.xml.(defType=edismax is used)
> <str name="qf">description</str> <str name="qf">category</str> <str name=
> "qf">title^4</str> <str name="qf">demand^0.3</str>
> <str name="mm">2&lt;-1 4&lt;-30%</str>
> 
> When I searched 'bags' as a search string, solr returned 15000 results.
> Query Used :
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=bags&qt=handler1&rows=10&wt=json
> 
> And when searched 'books' as a search string, solr returns say 3348 results.
> Query Used :
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=books&qt=handler1&rows=10&wt=json
> 
> I want to use both 'bags' and 'books' as a search string in a single query.
> I used the following query:
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=%22bags%22+OR+%22books%22&qt=handler1&rows=10&wt=json
> But OR operator not working. It will only give 7 results.
> 
> 
> I even tried this :
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=(bags)+OR+(books)&qt=handler1&rows=10&wt=json
> But it also gives 7 results.
> 
> But my concern is to include the result of both 'bags' OR 'books' in a
> single query.
> Is there any way to use two search strings in a single query?


Re: How to use two search string in a single solr query

Posted by Erick Erickson <er...@gmail.com>.
Please let s know what version of Solr you use, otherwise it’s very hard to know
whether you’re running into https://issues.apache.org/jira/browse/SOLR-8812
or similar.

But two things to try:
1> specify q.op
lr
2> specify mm=0%

Best,
Erick

> On Jul 2, 2020, at 1:22 AM, Tushar Arora <ta...@gmail.com> wrote:
> 
> Hi,
> I have a scenario with following entry in the request handler(handler1) of
> solrconfig.xml.(defType=edismax is used)
> <str name="qf">description</str> <str name="qf">category</str> <str name=
> "qf">title^4</str> <str name="qf">demand^0.3</str>
> <str name="mm">2&lt;-1 4&lt;-30%</str>
> 
> When I searched 'bags' as a search string, solr returned 15000 results.
> Query Used :
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=bags&qt=handler1&rows=10&wt=json
> 
> And when searched 'books' as a search string, solr returns say 3348 results.
> Query Used :
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=books&qt=handler1&rows=10&wt=json
> 
> I want to use both 'bags' and 'books' as a search string in a single query.
> I used the following query:
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=%22bags%22+OR+%22books%22&qt=handler1&rows=10&wt=json
> But OR operator not working. It will only give 7 results.
> 
> 
> I even tried this :
> http://localhost:8984/solr/core_name/select?fl=title&indent=on&q=(bags)+OR+(books)&qt=handler1&rows=10&wt=json
> But it also gives 7 results.
> 
> But my concern is to include the result of both 'bags' OR 'books' in a
> single query.
> Is there any way to use two search strings in a single query?