lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Ryan <>
Subject RE: Exact match on string field with special characters
Date Mon, 06 Oct 2014 14:52:53 GMT
This should do what you want:

String fq = "Field1" + "\"" + org.apache.solr.client.solrj.util.ClientUtils.escapeQueryChars(value)
+ "\"";


-----Original Message-----
From: tedsolr [] 
Sent: Monday, October 06, 2014 10:49 AM
Subject: Re: Exact match on string field with special characters

I may have provided too much background story for my question. What I am trying to do at the
core here, is an exact match on a single field. I do this programmatically by reading the
field value from the facet query and setting it equal to the field name for a subsequent search.

if this is a sample facet query result ... (Field1 is defined as a string) [Field1:[HI! THIS
IS A "VALUE" FOR \FIELD1\ (100)]

Then I need to run a search for that exact value. The problem is the double quotes and slashes
when I try to construct the facet query ...
String fq = "Field1:" + "\"" + value + "\"";

The quotes play havoc with the concatenation, as do backslashes. I was wondering if there's
a way to build the search without having to manually construct it in code. The only thing
I can come up with is to transform the field data at index time by replacing double quotes
and backslashes. I don't strip special chars because I'm using the facet values for display.
This problem may be specific to SolrJ. Thanks!

View this message in context:
Sent from the Solr - User mailing list archive at

View raw message