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 Tobias Hill <To...@citerus.se> on 2007/10/30 16:58:09 UTC
Looking for "Exact match but no other terms"... how to express it?
I want to match on the exact phrase "foo bar dot" on a
specific field on my set of documents.
I only want results where that field has exactly "foo bar dot"
and no more terms. I.e. A document with "foo bar dot alu"
should not match.
A phrase query with slop 0 seems resonable but how do I
express "but nothing more than these terms".
Thankful for your feedback on this!
Tobias
Re: Looking for "Exact match but no other terms"... how to express it?
Posted by Karl Wettin <ka...@gmail.com>.
30 okt 2007 kl. 16.58 skrev Tobias Hill:
>
> I only want results where that field has exactly "foo bar dot"
> and no more terms. I.e. A document with "foo bar dot alu"
> should not match.
>
> A phrase query with slop 0 seems resonable but how do I
> express "but nothing more than these terms".
There is no such feature in Lucene, however you could add prefix and
suffix tokens to your index and include these in your search, for
instance "^ foo bar dot alu $". This will however mess up your
SpanFirst-queries.
--
karl
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Looking for "Exact match but no other terms"... how to express it?
Posted by Paul Elschot <pa...@xs4all.nl>.
On Tuesday 30 October 2007 16:58:09 Tobias Hill wrote:
> I want to match on the exact phrase "foo bar dot" on a
> specific field on my set of documents.
>
> I only want results where that field has exactly "foo bar dot"
> and no more terms. I.e. A document with "foo bar dot alu"
> should not match.
>
> A phrase query with slop 0 seems resonable but how do I
> express "but nothing more than these terms".
Another way to do this is by indexing a special begin and end token before and
after the tokens of the field, and by extending your queries with these
special tokens, for example: "=begin= foo bar dot =end=" .
Regards,
Paul Elschot
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Looking for "Exact match but no other terms"... how to express
it?
Posted by John Byrne <jo...@propylon.com>.
Tobias Hill wrote:
> I want to match on the exact phrase "foo bar dot" on a
> specific field on my set of documents.
>
> I only want results where that field has exactly "foo bar dot"
> and no more terms. I.e. A document with "foo bar dot alu"
> should not match.
>
> A phrase query with slop 0 seems resonable but how do I
> express "but nothing more than these terms".
>
> Thankful for your feedback on this!
> Tobias
>
>
You can do this by storing the text in an un-tokenized field. This is an
option when you create the field. use "Field.Index.UN_TOKENIZED" as the
option when you create the field. Then individual terms or phrases will
not match that field. You will still be able to match it with the exact
text, a wildcard query, or a range query.
So in your case, if the field contained "foo bar dot" you would not get
a hit for "foo bar dot alu", but you would for "foo bar dot", "foo*",
"f*" or even "*".
Hope that helps!
Regards,
John.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org