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 Phil brunet <ph...@hotmail.com> on 2004/04/02 17:12:05 UTC

Performing exact search with Lucene

Hi all.

I'm migrating a part of an application from Oracle intermedia to Lucene 
(1.3) to perform full text searches.

I'd like to know if there is a way to perform "exact queries". By "exact 
query", i mean beeing able to match ONLY document that are exactely equals 
to the terms of the query.

Exemple:

document 1 =    "this is an example"
document 2 =    "this is an example of document"
document 3 =    "this is an other example "

Is it possible to match ONLY document 1 if i search for "this is an exemple" 
?

Currently, i'm trying to override the DefaultSimilarity class in order to be 
be able to deduce an exact match from the score.

My query consists in a BooleanQuery composed by n TermQuery.

I know i can develop by myself a "post filter" that could count compare the 
number of tokens of the query and the number of tokens of the indexed 
document. But i would like to know if there is a proper way to do this :
-> directly with Lucene (i.e. a Lucene query that would match only document 
1 in my example)
-> by redefining the Similarity and so by "interpreting" the scores
-> any idea ....

Thanks.

Philippe

_________________________________________________________________
Trouvez l'âme soeur sur MSN Rencontres http://g.msn.fr/FR1000/9551


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


Re: Performing exact search with Lucene

Posted by Tatu Saloranta <ta...@hypermall.net>.
On Friday 02 April 2004 08:12, Phil brunet wrote:
> Hi all.
>
> I'm migrating a part of an application from Oracle intermedia to Lucene
> (1.3) to perform full text searches.

Congratulations! :-)

> I'd like to know if there is a way to perform "exact queries". By "exact
> query", i mean beeing able to match ONLY document that are exactely equals
> to the terms of the query.

I believe plain old PhraseQuery does exactly that? You can build one yourself, 
or, using QueryParser, use something like

+"this is an example"

(making sure you use correct analyzer, depending on whether you want 'an' to 
be significant token in there).
Note, too, that '+' prefix in there is not absolutely needed, if you don't 
have multiple parts to the query; even without that it'd only consider 
documents that have that exact phrase.

-+ Tatu +-

>
> Exemple:
>
> document 1 =    "this is an example"
> document 2 =    "this is an example of document"
> document 3 =    "this is an other example "
>
> Is it possible to match ONLY document 1 if i search for "this is an
> exemple" ?
>
> Currently, i'm trying to override the DefaultSimilarity class in order to
> be be able to deduce an exact match from the score.
>
> My query consists in a BooleanQuery composed by n TermQuery.
>
> I know i can develop by myself a "post filter" that could count compare the
> number of tokens of the query and the number of tokens of the indexed
> document. But i would like to know if there is a proper way to do this :
> -> directly with Lucene (i.e. a Lucene query that would match only document
> 1 in my example)
> -> by redefining the Similarity and so by "interpreting" the scores
> -> any idea ....
>
> Thanks.
>
> Philippe
>
> _________________________________________________________________
> Trouvez l'âme soeur sur MSN Rencontres http://g.msn.fr/FR1000/9551
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


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