Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to search negative number in solr?

In solr I want to search one field with negative number like nodeId:-1. in schema.xml, I defined it like this: <field name="nodeId" type="int" indexed="true" stored="true" />

solr throws error when use "nodeId:-1" to search like this: org.apache.lucene.queryParser.ParseException: Cannot parse 'storeId:-1': Encountered " "-" "- "" at line 1, column 8. Was expecting one of: "(" ... "*" ... ... ... ... ... "[" ... "{" ... ...

I must search with storeId:\-1 or storeId:"-1" to get answer.

now the question is : Can I modify any solr configration files to search without any escape characters? Or another way to resolve this problem without modify java code. Thanks.

like image 817
user1058984 Avatar asked Nov 22 '11 03:11

user1058984


1 Answers

I personally think escaping properly inside your Java code is the better way. ClientUtils.escapeQueryChars would be the method of choice.

like image 67
jeha Avatar answered Sep 20 '22 12:09

jeha