Oh, I forgot to mention that this kind of question is better suited to the user's list, the dev list is primarily for discussion of internal Lucene development....
Best Erick On Wed, Oct 19, 2011 at 8:31 PM, Erick Erickson <[email protected]> wrote: > Right, term queries are NOT parsed, they assume you've > already done that (which you have in this case). which is > why you're finding that document with term query. > > So take a look at the query explain (toString?) and see > what the query is actually being parsed as. My guess is that > StandardAnalyzer is splitting this into two tokens so you're > not matching. > > There are two issues here. Escaping the - is just making it so > that the query parser doesn't interpret the hyphen as a NOT > operator. That says nothing about how the tokenizer (standard) > is breaking up the term after that. I expect you'd get your > expected results if you used, say, WhitespaceTokenizer... > > Best > Erick > > On Tue, Oct 18, 2011 at 8:47 PM, anne <[email protected]> wrote: >> Hi, >> I have a field that is not tokenized. Its value can contain a "-". >> For instance it could be "project-test". I have read that I need to escape >> this special character with a \ >> I am using the following code (StandardAnanyzer): >> Query query = queryParser.parse("field:project\\-test); >> >> and it doesn't retrieve my document. >> >> Is it because I need to use a TermQuery? >> I have tried with a TermQuery and it seems that in this case I don't need to >> escape the "-". >> >> Or is it because of the analyzer? >> >> Any help will be appreciated. Thanks a lot, >> Anne >> >> >> >> -- >> View this message in context: >> http://lucene.472066.n3.nabble.com/Escaping-special-character-tp3432118p3432118.html >> Sent from the Lucene - Java Developer mailing list archive at Nabble.com. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
