You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Deepak Gopalakrishnan <dg...@gmail.com> on 2015/02/17 17:57:43 UTC

Indexing Query

Hello,

I have a rather simple query. I have a list where I have terms like and
then my query is more natural language. I want to be able to retrieve
 matches that has atleast 2 words in common between the query and the index

Can you guys suggest a Query Type and a field that I should be using?

-- 
Regards,
*Deepak Gopalakrishnan*

Re: Indexing Query

Posted by Deepak Gopalakrishnan <dg...@gmail.com>.
Oops, alright, I'll probably look around for a workaround.

On Wed, Feb 18, 2015 at 3:24 PM, Ian Lea <ia...@gmail.com> wrote:

> You mean you'd like a BooleanQuery.setMaximumNumberShouldMatch()
> method?  Unfortunately that doesn't exist and I can't think of a
> simple way of doing it.
>
>
> --
> Ian.
>
>
> On Wed, Feb 18, 2015 at 5:26 AM, Deepak Gopalakrishnan <dg...@gmail.com>
> wrote:
> > Thanks Ian. Also, if I have a unigram in the query, and I want to make
> sure
> > I match only index entries that do not have more than 2 tokens, is there
> a
> > way to do that too?
> >
> > Thanks
> >
> > On Wed, Feb 18, 2015 at 2:23 AM, Ian Lea <ia...@gmail.com> wrote:
> >
> >> Break the query into words then add them as TermQuery instances as
> >> optional clauses to a BooleanQuery with a call to
> >> setMinimumNumberShouldMatch(2) somewhere along the line.  You may want
> >> to do some parsing or analysis on the query terms to avoid problems of
> >> case matching and the like.
> >>
> >>
> >> --
> >> Ian.
> >>
> >>
> >> On Tue, Feb 17, 2015 at 4:57 PM, Deepak Gopalakrishnan <
> dgkris@gmail.com>
> >> wrote:
> >> > Hello,
> >> >
> >> > I have a rather simple query. I have a list where I have terms like
> and
> >> > then my query is more natural language. I want to be able to retrieve
> >> >  matches that has atleast 2 words in common between the query and the
> >> index
> >> >
> >> > Can you guys suggest a Query Type and a field that I should be using?
> >> >
> >> > --
> >> > Regards,
> >> > *Deepak Gopalakrishnan*
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
> >
> >
> > --
> > Regards,
> > *Deepak Gopalakrishnan*
> > *Mobile*:+918891509774
> > *Skype* : deepakgk87
> > http://myexps.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Regards,
*Deepak Gopalakrishnan*
*Mobile*:+918891509774
*Skype* : deepakgk87
http://myexps.blogspot.com

Re: Indexing Query

Posted by Jack Krupansky <ja...@gmail.com>.
You could store the length of the field (in terms) in a second field and
then add a MUST term to the BooleanQuery which is a RangeQuery with an
upper bound that is the maximum length that can match.

-- Jack Krupansky

On Wed, Feb 18, 2015 at 4:54 AM, Ian Lea <ia...@gmail.com> wrote:

> You mean you'd like a BooleanQuery.setMaximumNumberShouldMatch()
> method?  Unfortunately that doesn't exist and I can't think of a
> simple way of doing it.
>
>
> --
> Ian.
>
>
> On Wed, Feb 18, 2015 at 5:26 AM, Deepak Gopalakrishnan <dg...@gmail.com>
> wrote:
> > Thanks Ian. Also, if I have a unigram in the query, and I want to make
> sure
> > I match only index entries that do not have more than 2 tokens, is there
> a
> > way to do that too?
> >
> > Thanks
> >
> > On Wed, Feb 18, 2015 at 2:23 AM, Ian Lea <ia...@gmail.com> wrote:
> >
> >> Break the query into words then add them as TermQuery instances as
> >> optional clauses to a BooleanQuery with a call to
> >> setMinimumNumberShouldMatch(2) somewhere along the line.  You may want
> >> to do some parsing or analysis on the query terms to avoid problems of
> >> case matching and the like.
> >>
> >>
> >> --
> >> Ian.
> >>
> >>
> >> On Tue, Feb 17, 2015 at 4:57 PM, Deepak Gopalakrishnan <
> dgkris@gmail.com>
> >> wrote:
> >> > Hello,
> >> >
> >> > I have a rather simple query. I have a list where I have terms like
> and
> >> > then my query is more natural language. I want to be able to retrieve
> >> >  matches that has atleast 2 words in common between the query and the
> >> index
> >> >
> >> > Can you guys suggest a Query Type and a field that I should be using?
> >> >
> >> > --
> >> > Regards,
> >> > *Deepak Gopalakrishnan*
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
> >
> >
> > --
> > Regards,
> > *Deepak Gopalakrishnan*
> > *Mobile*:+918891509774
> > *Skype* : deepakgk87
> > http://myexps.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Indexing Query

Posted by Ian Lea <ia...@gmail.com>.
You mean you'd like a BooleanQuery.setMaximumNumberShouldMatch()
method?  Unfortunately that doesn't exist and I can't think of a
simple way of doing it.


--
Ian.


On Wed, Feb 18, 2015 at 5:26 AM, Deepak Gopalakrishnan <dg...@gmail.com> wrote:
> Thanks Ian. Also, if I have a unigram in the query, and I want to make sure
> I match only index entries that do not have more than 2 tokens, is there a
> way to do that too?
>
> Thanks
>
> On Wed, Feb 18, 2015 at 2:23 AM, Ian Lea <ia...@gmail.com> wrote:
>
>> Break the query into words then add them as TermQuery instances as
>> optional clauses to a BooleanQuery with a call to
>> setMinimumNumberShouldMatch(2) somewhere along the line.  You may want
>> to do some parsing or analysis on the query terms to avoid problems of
>> case matching and the like.
>>
>>
>> --
>> Ian.
>>
>>
>> On Tue, Feb 17, 2015 at 4:57 PM, Deepak Gopalakrishnan <dg...@gmail.com>
>> wrote:
>> > Hello,
>> >
>> > I have a rather simple query. I have a list where I have terms like and
>> > then my query is more natural language. I want to be able to retrieve
>> >  matches that has atleast 2 words in common between the query and the
>> index
>> >
>> > Can you guys suggest a Query Type and a field that I should be using?
>> >
>> > --
>> > Regards,
>> > *Deepak Gopalakrishnan*
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>
>
> --
> Regards,
> *Deepak Gopalakrishnan*
> *Mobile*:+918891509774
> *Skype* : deepakgk87
> http://myexps.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Indexing Query

Posted by Deepak Gopalakrishnan <dg...@gmail.com>.
Thanks Ian. Also, if I have a unigram in the query, and I want to make sure
I match only index entries that do not have more than 2 tokens, is there a
way to do that too?

Thanks

On Wed, Feb 18, 2015 at 2:23 AM, Ian Lea <ia...@gmail.com> wrote:

> Break the query into words then add them as TermQuery instances as
> optional clauses to a BooleanQuery with a call to
> setMinimumNumberShouldMatch(2) somewhere along the line.  You may want
> to do some parsing or analysis on the query terms to avoid problems of
> case matching and the like.
>
>
> --
> Ian.
>
>
> On Tue, Feb 17, 2015 at 4:57 PM, Deepak Gopalakrishnan <dg...@gmail.com>
> wrote:
> > Hello,
> >
> > I have a rather simple query. I have a list where I have terms like and
> > then my query is more natural language. I want to be able to retrieve
> >  matches that has atleast 2 words in common between the query and the
> index
> >
> > Can you guys suggest a Query Type and a field that I should be using?
> >
> > --
> > Regards,
> > *Deepak Gopalakrishnan*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Regards,
*Deepak Gopalakrishnan*
*Mobile*:+918891509774
*Skype* : deepakgk87
http://myexps.blogspot.com

Re: Indexing Query

Posted by Ian Lea <ia...@gmail.com>.
Break the query into words then add them as TermQuery instances as
optional clauses to a BooleanQuery with a call to
setMinimumNumberShouldMatch(2) somewhere along the line.  You may want
to do some parsing or analysis on the query terms to avoid problems of
case matching and the like.


--
Ian.


On Tue, Feb 17, 2015 at 4:57 PM, Deepak Gopalakrishnan <dg...@gmail.com> wrote:
> Hello,
>
> I have a rather simple query. I have a list where I have terms like and
> then my query is more natural language. I want to be able to retrieve
>  matches that has atleast 2 words in common between the query and the index
>
> Can you guys suggest a Query Type and a field that I should be using?
>
> --
> Regards,
> *Deepak Gopalakrishnan*

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org