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 Shakti_Sareen <Sh...@satyam.com> on 2007/12/12 09:54:19 UTC

(~) opertor query....

 

Hi All,

          I am parsing this query:  "Auto*  machine"~4.

          Will it work? If yes then right now it's not working. Can
anyone help on this?

 

Thanks & Regards

Shakti Sareen

 

 

 

 



DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.

Re: (~) opertor query....

Posted by Shai Erera <se...@gmail.com>.
I just noticed MultiPhraseQuery has a setSlop method, so I think this Query
is what you're looking for.

On Dec 15, 2007 7:04 AM, Shai Erera <se...@gmail.com> wrote:

> You can look at org.apache.lucene.search.MultiPhraseQuery which does
> something similar to what you ask. From its javadoc:
>
>  * To use this class, to search for the phrase "Microsoft app*" first use
>  * add(Term) on the term "Microsoft", then find all terms that have "app"
> as
>  * prefix using IndexReader.terms(Term), and use MultiPhraseQuery.add
> (Term[]
>  * terms) to add them to the query.
>
> It works for simple phrases and I don't know if it works for fuzzy phrases
> as well ... however I believe it can be tweaked to work for fuzzy phrases
> also.
>
>
> On Dec 15, 2007 1:26 AM, Chris Hostetter <ho...@fucit.org> wrote:
>
> >
> > :           I am parsing this query:  "Auto*  machine"~4.
> > :
> > :           Will it work? If yes then right now it's not working. Can
> > : anyone help on this?
> >
> > Tt depends, what do you want it to do?  :)
> >
> > If you are hoping it will match documents that contain a word that
> > starts
> > with "Auto" withing a distance of 4 words from the word "machine" then
> > no,
> > the query parser doesn't work that way.  phrase queries (aka: proximty
> > queries) as supported by the QueryParser can only match simple words in
> > the phrase, not other complex query types ... but you could build your
> > own
> > query parser that leveraged the SpanQuery family of queries to do
> > something like this.
> >
> >
> >
> > -Hoss
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>
>
> --
> Regards,
>
> Shai Erera




-- 
Regards,

Shai Erera

Re: (~) opertor query....

Posted by Chris Hostetter <ho...@fucit.org>.
: You can look at org.apache.lucene.search.MultiPhraseQuery which does
: something similar to what you ask. From its javadoc:

good call .. funny thing, i was just pointing out MultiPhraseQuery as a 
way to meat this need only a few days ago, but for some reason it didn't 
occur to me in the thread.

if you build a custom query parser, you can easily use the 
WildCardTermEnumerator to get the list of all matching terms to use to 
build up a MultiPhraseQuery.


: > :           I am parsing this query:  "Auto*  machine"~4.


-Hoss


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


Re: (~) opertor query....

Posted by Shai Erera <se...@gmail.com>.
You can look at org.apache.lucene.search.MultiPhraseQuery which does
something similar to what you ask. From its javadoc:

 * To use this class, to search for the phrase "Microsoft app*" first use
 * add(Term) on the term "Microsoft", then find all terms that have "app" as
 * prefix using IndexReader.terms(Term), and use MultiPhraseQuery.add(Term[]
 * terms) to add them to the query.

It works for simple phrases and I don't know if it works for fuzzy phrases
as well ... however I believe it can be tweaked to work for fuzzy phrases
also.

On Dec 15, 2007 1:26 AM, Chris Hostetter <ho...@fucit.org> wrote:

>
> :           I am parsing this query:  "Auto*  machine"~4.
> :
> :           Will it work? If yes then right now it's not working. Can
> : anyone help on this?
>
> Tt depends, what do you want it to do?  :)
>
> If you are hoping it will match documents that contain a word that starts
> with "Auto" withing a distance of 4 words from the word "machine" then no,
> the query parser doesn't work that way.  phrase queries (aka: proximty
> queries) as supported by the QueryParser can only match simple words in
> the phrase, not other complex query types ... but you could build your own
> query parser that leveraged the SpanQuery family of queries to do
> something like this.
>
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Regards,

Shai Erera

Re: (~) opertor query....

Posted by Chris Hostetter <ho...@fucit.org>.
:           I am parsing this query:  "Auto*  machine"~4.
: 
:           Will it work? If yes then right now it's not working. Can
: anyone help on this?

Tt depends, what do you want it to do?  :)

If you are hoping it will match documents that contain a word that starts 
with "Auto" withing a distance of 4 words from the word "machine" then no, 
the query parser doesn't work that way.  phrase queries (aka: proximty 
queries) as supported by the QueryParser can only match simple words in 
the phrase, not other complex query types ... but you could build your own 
query parser that leveraged the SpanQuery family of queries to do 
something like this.



-Hoss


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