Trevor,

You might use PhraseQuery and adjust the slop factor.  However, what exactly is 
meant by "exact"?

For example, the  StandardAnalyzer will tokenize the text "Bob is smiling" to 
two tokens, 'bob' and 'smiling' (note the lowercasing as well as the dropped 
'is'). Clearly, "bob is smiling" is not exactly "Bob is smiling", so it all 
hinges on what is meant by "exact".






-----Original Message-----
From: Trevor Watson [mailto:[email protected]] 
Sent: Monday, August 17, 2009 4:55 PM
To: [email protected]
Subject: Document equals, not contains

Last question for the day for you folks :)

We've written the code for our webservice to do a "contains" search with 
Lucene.NET (easy thanks to the developers).

Now the next part they added to it (development and planning in one go, 
/slaps project lead's hand) is to do a "Is Exactly" and "Is Not Exactly" 
searches.

I know we could do this by doing a search and looking for anything with 
a score of _near_ 1. (even copied/pasted stuff gave me 0.99999994 
scores, my guess is due to punctuation), however, we're using the 
Lucene.Net.QueryParsers.QueryParser and Lucene.Net.Search.Query to allow 
multiple clauses in the query.  So I can't do "Is exactly "Bob is 
smiling"" then just loop through the returned values' scores.  (instead 
we want to do "Field1 Is Exactly "Bob is smiling" AND Field2 Contains 
"happy" AND Field3 does not contain "Dancing ensued")

Is it possible to add anything to the query to restrict the scores 
returned in Lucene.Net?  For example, "Bob is happy"$0.9 would return 
anything with a 0.9 score or higher.

Any advice would be greatly appreciated.

Trevor Watson

Reply via email to