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







Reply via email to