lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Escaping special character -
Date Wed, 19 Oct 2011 18:32:06 GMT
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 <erickerickson@gmail.com> 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 <asrosset@gmail.com> 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: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>>
>

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


Mime
View raw message