I'm still not clear why the built-in phrase query syntax won't work. If I
index the following terms (erick, erickson, thinks, small, thoughts)
in a single field, then searching for "erick erickson" (as a phrase query,
i.e. with double quotes when sent through a query parser or constructing
a PhraseQuery yourself) will generate a hit but "erick thinks" won't
generate a hit (unless you specify slop).

"thinks small thoughts" would also generate a hit

If you're saying that you only want to match on *all* the tokens, i.e.
the only way to get a hit on the above would be to search for
"erick erickson thinks small thoughts", then you can create a
field that's UN_ANALYZED. If you do this, though, beware
that you have to do things like lower-case terms yourself when
indexing.

I have no idea what IndexTermGenerator is or what it does, but I'm
assuming that it just generates single words.

Some examples of what you put in your index and what searches
you expect to return results for your example AND searches you do
NOT want to hit that document would be a great help.

As far as searching for both, constructing a BooleanQuery with regular
TermQuerys and PhraseQuerys would work if you're constructing
your queries programmatically, or just using a Lucene query
like +termfield:word +phrasefield:"erick erickson thinks" would
work. Or, if you just require that the phrase exists you could do
it all in one field like
+field:word +field:"erick erickson thinks"



Best
Erick


On Wed, Feb 18, 2009 at 8:42 AM, Nada Mimouni <
mimo...@tk.informatik.tu-darmstadt.de> wrote:

>
>
> Thank you Erick.
>
> I need first to index phrases, the built-in phrase processing (with double
> quotes) comes in the search step.
> Is there any difference between :
>            1) start by indexing phrases and then make a phrase search
>            2) index terms and then search for phrases
>
>
> To make things clearer:
>
> What I am doing now:
>  - In the indexing step:  I am using "IndexTermGenerator" to generate term
> based indexes, one index for all queries I have and another one for
> documents (term means single word).
>  - In the search step : Lucene matches terms in queries index with terms in
> documents index.
>
> What I need to do:
>  - Index phrases ("multi" words) in addition to terms (single words)
>  - Search for both : phrases and terms
>
>
> Is there any idea on how to proceed?
>
> Regards
> Nada
>
>
> -----Original Message-----
> From: Erick Erickson [mailto:erickerick...@gmail.com]
> Sent: Wed 2/18/2009 2:10 PM
> To: java-user@lucene.apache.org
> Subject: Re: Phrase indexing and searching with Lucene
>
> Have you tried the built-in phrase processing with double quotes? e.g.
> "this is a phrase"?
>
> See the Term section at
> http://lucene.apache.org/java/2_4_0/queryparsersyntax.html
>
> Best
> Erick
>
> On Wed, Feb 18, 2009 at 5:57 AM, Nada Mimouni <
> mimo...@tk.informatik.tu-darmstadt.de> wrote:
>
> >
> >
> > Hello everybody,
> >
> > I use Lucene to index and search into text documents.
> > At present, I just index and search for single words. I want to extend
> this
> > to phrases (or nGrams).
> >
> > Could anyone please give me details on how to index phrases and then make
> a
> > phrase search?
> >
> > Thank you very much in advance for your help.
> >
> > Nada Mimouni
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> > For additional commands, e-mail: java-user-h...@lucene.apache.org
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>

Reply via email to