Search code examples
javasolrsolrj

How do you specify a filter query with Solrj with embedded whitespace?


I am using SolrJ to search Solr.

My application works fine until I receive a filter query with embedded whitespace

I have tried the following formats

String filterQuery_1 = "\"xxx xxx xxx\"*";
String filterQuery_2 = "xxx\\ xxx\\ xxx*";
String filterQuery_3 = "(xxx xxx xxx)*";

none give satisfactory results

They either result in no filtering being applied at all or I get rows that do not appear to have any relationship to what I have filtered on

How do you search solr with solrj with filter strings that have embedded whitespace?

****** UPDATE 0001 ******

All the text fields I am attempting to search with embedded blanks are defined as follows:-

<field name="TEXT_FIELD_00001" type="text_general" indexed="true" stored="true" />

These fields contain postal address details.

e.g.

     123 My Road
     My Town
     My County
     My Country
     AA1  1AA

Solution

  • I guess you trying something like this - Solr exact search with blank character AND a wildcard

    This is works, but depends of configuration schema(field definition) this can be broken.

    Can you try check this querying Solr manually(from admin panel or using REST api)? Just to avoid any possibility of incorect escaping what can SolrJ can do. If the filter query works correctly we can try investigate issue with SolrJ. Otherwise - you should review your schema.