FAQ
Hi guys,
We're migrating from Lucene to Solr. We have a lot of existing code
that created queries in memory with Lucene. Below is an example of such
a query.


BooleanQuery query = new BooleanQuery();

BooleanQuery inputTerms = new BooleanQuery();
inputTerms.add(new TermQuery(new Term(FIELD_EMAIL, input)),
Occur.SHOULD);

String numeric = getNumericString(input);

if (StringUtils.hasText(numeric)) {
inputTerms.add(new TermQuery(new Term(FIELD_PHONE, numeric)),
Occur.SHOULD);
}

query.add(inputTerms, Occur.MUST);

NumericRangeQuery time = NumericRangeQuery.newLongRange(
FIELD_CREATETIME, null, endTime, true, true);

query.add(time, Occur.MUST);

return getResults(query, count);


As per an old thread in the mailing list, I can generally call
query.toString() which will generate a query I can send to solr.
However, we're getting some strings such as this.

+(email_string_multi_index:+6411122222
phone_string_multi_index:6411122222) +rslved_string_index:false
+crttime_long_index:[* TO 1284093338200]':

Which will generate this error Encountered " "+" "+ "" at line 1, column
27.

The cause is the "+6411122222".

Is there an equivalent for building a query tree in the Solr4j client
that will properly escape the input sequence?

Thanks,
Todd

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedFeb 10, '11 at 9:28p
activeFeb 10, '11 at 9:28p
posts1
users1
websitelucene.apache.org

1 user in discussion

Todd Nine: 1 post

People

Translate

site design / logo © 2022 Grokbase