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 S Eslamian <se...@gmail.com> on 2012/04/24 11:44:28 UTC

searching minus digit

How can I search a minus digit like -123 in lucene?
When I search this,lucene excludes 123 from my search or returns no answer.

Re: searching minus digit

Posted by Erick Erickson <er...@gmail.com>.
Does any part of your analysis chain remove the -? It's a common
thing to see happen, there are often cases where the search
experience is better when hyphens are removed, and some tokenizers
do this automatically.


Best
Erick

On Tue, Apr 24, 2012 at 8:04 AM, S Eslamian <se...@gmail.com> wrote:
> Hi  :)
> I don't why, but searching "\\-1234" ignores negative point and search for
> 1234 !
>
> On Tue, Apr 24, 2012 at 4:24 PM, G.Long <jd...@gmail.com> wrote:
>
>> Hi :)
>>
>> Did you try with "\\-1234" ?
>>
>> Regards
>>
>> Le 24/04/2012 13:40, S Eslamian a écrit :
>>
>>  Thank you but when I search this : Query termQuery = new TermQuery
>>> ("field","\-1234"); I get this exception :
>>> Invalid escape sequence (valid one are \b \t \n \f \r \" \' \\)
>>>
>>> Am I making mistake in creating my query?
>>>
>>> On Tue, Apr 24, 2012 at 3:52 PM, Erick Erickson<er...@gmail.com>
>>> >wrote:
>>>
>>>  the - is part of the query syntax, you must escape it. See:
>>>>
>>>>
>>>> http://lucene.apache.org/core/**old_versioned_docs/versions/3_**
>>>> 5_0/queryparsersyntax.html<http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html>
>>>>
>>>> Best
>>>> Erick
>>>>
>>>> On Tue, Apr 24, 2012 at 5:44 AM, S Eslamian<se...@gmail.com>  wrote:
>>>>
>>>>> How can I search a minus digit like -123 in lucene?
>>>>> When I search this,lucene excludes 123 from my search or returns no
>>>>>
>>>> answer.
>>>>
>>>> ------------------------------**------------------------------**
>>>> ---------
>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.**apache.org<ja...@lucene.apache.org>
>>>> For additional commands, e-mail: java-user-help@lucene.apache.**org<ja...@lucene.apache.org>
>>>>
>>>>
>>>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.**apache.org<ja...@lucene.apache.org>
>> For additional commands, e-mail: java-user-help@lucene.apache.**org<ja...@lucene.apache.org>
>>
>>

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


Re: searching minus digit

Posted by S Eslamian <se...@gmail.com>.
Hi  :)
I don't why, but searching "\\-1234" ignores negative point and search for
1234 !

On Tue, Apr 24, 2012 at 4:24 PM, G.Long <jd...@gmail.com> wrote:

> Hi :)
>
> Did you try with "\\-1234" ?
>
> Regards
>
> Le 24/04/2012 13:40, S Eslamian a écrit :
>
>  Thank you but when I search this : Query termQuery = new TermQuery
>> ("field","\-1234"); I get this exception :
>> Invalid escape sequence (valid one are \b \t \n \f \r \" \' \\)
>>
>> Am I making mistake in creating my query?
>>
>> On Tue, Apr 24, 2012 at 3:52 PM, Erick Erickson<er...@gmail.com>
>> >wrote:
>>
>>  the - is part of the query syntax, you must escape it. See:
>>>
>>>
>>> http://lucene.apache.org/core/**old_versioned_docs/versions/3_**
>>> 5_0/queryparsersyntax.html<http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html>
>>>
>>> Best
>>> Erick
>>>
>>> On Tue, Apr 24, 2012 at 5:44 AM, S Eslamian<se...@gmail.com>  wrote:
>>>
>>>> How can I search a minus digit like -123 in lucene?
>>>> When I search this,lucene excludes 123 from my search or returns no
>>>>
>>> answer.
>>>
>>> ------------------------------**------------------------------**
>>> ---------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.**apache.org<ja...@lucene.apache.org>
>>> For additional commands, e-mail: java-user-help@lucene.apache.**org<ja...@lucene.apache.org>
>>>
>>>
>>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.**apache.org<ja...@lucene.apache.org>
> For additional commands, e-mail: java-user-help@lucene.apache.**org<ja...@lucene.apache.org>
>
>

Re: searching minus digit

Posted by "G.Long" <jd...@gmail.com>.
Hi :)

Did you try with "\\-1234" ?

Regards

Le 24/04/2012 13:40, S Eslamian a écrit :
> Thank you but when I search this : Query termQuery = new TermQuery
> ("field","\-1234"); I get this exception :
> Invalid escape sequence (valid one are \b \t \n \f \r \" \' \\)
>
> Am I making mistake in creating my query?
>
> On Tue, Apr 24, 2012 at 3:52 PM, Erick Erickson<er...@gmail.com>wrote:
>
>> the - is part of the query syntax, you must escape it. See:
>>
>>
>> http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html
>>
>> Best
>> Erick
>>
>> On Tue, Apr 24, 2012 at 5:44 AM, S Eslamian<se...@gmail.com>  wrote:
>>> How can I search a minus digit like -123 in lucene?
>>> When I search this,lucene excludes 123 from my search or returns no
>> answer.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>


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


Re: searching minus digit

Posted by S Eslamian <se...@gmail.com>.
Thank you but when I search this : Query termQuery = new TermQuery
("field","\-1234"); I get this exception :
Invalid escape sequence (valid one are \b \t \n \f \r \" \' \\)

Am I making mistake in creating my query?

On Tue, Apr 24, 2012 at 3:52 PM, Erick Erickson <er...@gmail.com>wrote:

> the - is part of the query syntax, you must escape it. See:
>
>
> http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html
>
> Best
> Erick
>
> On Tue, Apr 24, 2012 at 5:44 AM, S Eslamian <se...@gmail.com> wrote:
> > How can I search a minus digit like -123 in lucene?
> > When I search this,lucene excludes 123 from my search or returns no
> answer.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: searching minus digit

Posted by Erick Erickson <er...@gmail.com>.
the - is part of the query syntax, you must escape it. See:

http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html

Best
Erick

On Tue, Apr 24, 2012 at 5:44 AM, S Eslamian <se...@gmail.com> wrote:
> How can I search a minus digit like -123 in lucene?
> When I search this,lucene excludes 123 from my search or returns no answer.

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