Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

searching minus digit

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


seslamian at gmail

Apr 24, 2012, 2:44 AM

Post #1 of 6 (221 views)
Permalink
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.


erickerickson at gmail

Apr 24, 2012, 4:22 AM

Post #2 of 6 (208 views)
Permalink
Re: searching minus digit [In reply to]

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 <seslamian [at] gmail> 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 [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


seslamian at gmail

Apr 24, 2012, 4:40 AM

Post #3 of 6 (206 views)
Permalink
Re: searching minus digit [In reply to]

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 <erickerickson [at] gmail>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 <seslamian [at] gmail> 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 [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>


jdevgl at gmail

Apr 24, 2012, 4:54 AM

Post #4 of 6 (209 views)
Permalink
Re: searching minus digit [In reply to]

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<erickerickson [at] gmail>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<seslamian [at] gmail> 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 [at] lucene
>> For additional commands, e-mail: java-user-help [at] lucene
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


seslamian at gmail

Apr 24, 2012, 5:04 AM

Post #5 of 6 (206 views)
Permalink
Re: searching minus digit [In reply to]

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 <jdevgl [at] gmail> 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<erickerickson [at] gmail**com<erickerickson [at] gmail>
>> >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<seslamian [at] gmail> 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 [at] lucene**apache.org<java-user-unsubscribe [at] lucene>
>>> For additional commands, e-mail: java-user-help [at] lucene**org<java-user-help [at] lucene>
>>>
>>>
>>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene**apache.org<java-user-unsubscribe [at] lucene>
> For additional commands, e-mail: java-user-help [at] lucene**org<java-user-help [at] lucene>
>
>


erickerickson at gmail

Apr 24, 2012, 7:59 AM

Post #6 of 6 (210 views)
Permalink
Re: searching minus digit [In reply to]

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 <seslamian [at] gmail> 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 <jdevgl [at] gmail> 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<erickerickson [at] gmail**com<erickerickson [at] gmail>
>>> >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<seslamian [at] gmail>  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 [at] lucene**apache.org<java-user-unsubscribe [at] lucene>
>>>> For additional commands, e-mail: java-user-help [at] lucene**org<java-user-help [at] lucene>
>>>>
>>>>
>>>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene**apache.org<java-user-unsubscribe [at] lucene>
>> For additional commands, e-mail: java-user-help [at] lucene**org<java-user-help [at] lucene>
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.