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 Kamal Palei <pa...@gmail.com> on 2013/05/13 15:56:00 UTC

Can we search some mandatory words and some optional words in SOLR

Dear SOLR Experts
Llets say I want to search some mandatory words and some optional words.
Say I want to search all documents those contains all *Java, mysql,
php*keywords along with atleast one keyword out of
* TCL, Perl, Selenium*.

*Basically I am looking at few mandatory keywords and few optional keywords.
*

Is it possible to search this way. If so, kindly guide me how the query
should look like.

Best Regards
Kamal

Re: Can we search some mandatory words and some optional words in SOLR

Posted by Kamal Palei <pa...@gmail.com>.
Thanks Hoss, I modified accordingly.
One more thing I observed, if I give search key as one of the below

1. +Java +mysql +php +(TCL Perl Selenium) -ethernet -switching -routing
2. +(TCL Perl Selenium) -ethernet -switching -routing
3. +(TCL Perl Selenium)

It works as expected. Like if key is +(TCL Perl Selenium) , then it
searches documents having atleast one or more  keyword out of TCL Perl
Selenium.

Best Regards
Kamal






On Wed, May 15, 2013 at 10:58 PM, Chris Hostetter
<ho...@fucit.org>wrote:

>
> : +Java +mysql +php TCL Perl Selenium -ethernet -switching -routing
>
> that's missing one of the started requirements...
>
> : 2. Atleast one keyword out of* TCL Perl Selenium* should be present
>
> ...should be...
>
>    +Java +mysql +php +(TCL Perl Selenium) -ethernet -switching -routing
>
>
> -Hoss
>

Re: Can we search some mandatory words and some optional words in SOLR

Posted by Jack Krupansky <ja...@basetechnology.com>.
Yeah, I keep forgetting that "min should match" for a BooleanQuery defaults 
to 1 only if there are no required terms, but if there are required terms it 
defaults to 0.

-- Jack Krupansky

-----Original Message----- 
From: Chris Hostetter
Sent: Wednesday, May 15, 2013 1:28 PM
To: solr-user@lucene.apache.org
Subject: Re: Can we search some mandatory words and some optional words in 
SOLR


: +Java +mysql +php TCL Perl Selenium -ethernet -switching -routing

that's missing one of the started requirements...

: 2. Atleast one keyword out of* TCL Perl Selenium* should be present

...should be...

   +Java +mysql +php +(TCL Perl Selenium) -ethernet -switching -routing


-Hoss 


Re: Can we search some mandatory words and some optional words in SOLR

Posted by Kamal Palei <pa...@gmail.com>.
Hi Hoss
I was wondering between this two keys. Though they look similar, but result
set differs.

In 1st case I give key as

+c +c++ +sip +( *tcl* perl "shell script") -"manual testing" -ss7


In 2nd case I give key as

+c +c++ +sip +(*tcl* perl "shell script") -"manual testing" -ss7

Please note that before *tcl* , space is not present in 2nd case.

In 1st case I get more results, and in 2nd case I get only 3 results.
In first case, I see atleast one result was there, which does not have
single optional key (means one document that does not contain either tcl or
perl or "shell script"). Is it a known issue.., please help..

Or I am doing something wrong in key preparation, please let me know.

Thanks
Kamal













On Wed, May 15, 2013 at 10:58 PM, Chris Hostetter
<ho...@fucit.org>wrote:

>
> : +Java +mysql +php TCL Perl Selenium -ethernet -switching -routing
>
> that's missing one of the started requirements...
>
> : 2. Atleast one keyword out of* TCL Perl Selenium* should be present
>
> ...should be...
>
>    +Java +mysql +php +(TCL Perl Selenium) -ethernet -switching -routing
>
>
> -Hoss
>

Re: Can we search some mandatory words and some optional words in SOLR

Posted by Chris Hostetter <ho...@fucit.org>.
: +Java +mysql +php TCL Perl Selenium -ethernet -switching -routing

that's missing one of the started requirements...

: 2. Atleast one keyword out of* TCL Perl Selenium* should be present

...should be...

   +Java +mysql +php +(TCL Perl Selenium) -ethernet -switching -routing


-Hoss

Re: Can we search some mandatory words and some optional words in SOLR

Posted by Jack Krupansky <ja...@basetechnology.com>.
That's also part of the basic, traditional Lucene search syntax:

+Java +mysql +php TCL Perl Selenium -ethernet -switching -routing

-- Jack Krupansky

-----Original Message----- 
From: Kamal Palei
Sent: Tuesday, May 14, 2013 8:33 AM
To: solr-user@lucene.apache.org
Subject: Re: Can we search some mandatory words and some optional words in 
SOLR

Thanks Jack Krupansky
Your solution having key as* **+Java +mysql +php TCL Perl Selenium* worked
nicely.

If I have to extend it something like, I need to search all documents,
those have

1. Mandatory Keywords present are *Java, MySql*
2. Atleast one keyword out of* TCL Perl Selenium* should be present
3. The keywords *ethernet, switching, routing*  should not be present

in document. In that case, how the search key should look like.

Best Regards
Kamal


On Mon, May 13, 2013 at 8:10 PM, Jack Krupansky 
<ja...@basetechnology.com>wrote:

> That's simply a standard, old-fashioned Lucene query:
>
> +Java +mysql +php TCL Perl Selenium
>
> And you can decide if "min should match" (mm) is 0, 1, 2, 3, etc. for the
> optional terms (TCL, Perl, Selenium)
>
> -- Jack Krupansky
>
> -----Original Message----- From: Kamal Palei
> Sent: Monday, May 13, 2013 9:56 AM
> To: solr-user@lucene.apache.org
> Subject: Can we search some mandatory words and some optional words in 
> SOLR
>
>
> Dear SOLR Experts
> Llets say I want to search some mandatory words and some optional words.
> Say I want to search all documents those contains all *Java, mysql,
> php*keywords along with atleast one keyword out of
> * TCL, Perl, Selenium*.
>
> *Basically I am looking at few mandatory keywords and few optional
> keywords.
>
> *
>
> Is it possible to search this way. If so, kindly guide me how the query
> should look like.
>
> Best Regards
> Kamal
> 


Re: Can we search some mandatory words and some optional words in SOLR

Posted by Kamal Palei <pa...@gmail.com>.
Thanks Jack Krupansky
Your solution having key as* **+Java +mysql +php TCL Perl Selenium* worked
nicely.

If I have to extend it something like, I need to search all documents,
those have

1. Mandatory Keywords present are *Java, MySql*
2. Atleast one keyword out of* TCL Perl Selenium* should be present
3. The keywords *ethernet, switching, routing*  should not be present

in document. In that case, how the search key should look like.

Best Regards
Kamal


On Mon, May 13, 2013 at 8:10 PM, Jack Krupansky <ja...@basetechnology.com>wrote:

> That's simply a standard, old-fashioned Lucene query:
>
> +Java +mysql +php TCL Perl Selenium
>
> And you can decide if "min should match" (mm) is 0, 1, 2, 3, etc. for the
> optional terms (TCL, Perl, Selenium)
>
> -- Jack Krupansky
>
> -----Original Message----- From: Kamal Palei
> Sent: Monday, May 13, 2013 9:56 AM
> To: solr-user@lucene.apache.org
> Subject: Can we search some mandatory words and some optional words in SOLR
>
>
> Dear SOLR Experts
> Llets say I want to search some mandatory words and some optional words.
> Say I want to search all documents those contains all *Java, mysql,
> php*keywords along with atleast one keyword out of
> * TCL, Perl, Selenium*.
>
> *Basically I am looking at few mandatory keywords and few optional
> keywords.
>
> *
>
> Is it possible to search this way. If so, kindly guide me how the query
> should look like.
>
> Best Regards
> Kamal
>

Re: Can we search some mandatory words and some optional words in SOLR

Posted by Jack Krupansky <ja...@basetechnology.com>.
That's simply a standard, old-fashioned Lucene query:

+Java +mysql +php TCL Perl Selenium

And you can decide if "min should match" (mm) is 0, 1, 2, 3, etc. for the 
optional terms (TCL, Perl, Selenium)

-- Jack Krupansky

-----Original Message----- 
From: Kamal Palei
Sent: Monday, May 13, 2013 9:56 AM
To: solr-user@lucene.apache.org
Subject: Can we search some mandatory words and some optional words in SOLR

Dear SOLR Experts
Llets say I want to search some mandatory words and some optional words.
Say I want to search all documents those contains all *Java, mysql,
php*keywords along with atleast one keyword out of
* TCL, Perl, Selenium*.

*Basically I am looking at few mandatory keywords and few optional keywords.
*

Is it possible to search this way. If so, kindly guide me how the query
should look like.

Best Regards
Kamal