lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Ryan <mr...@moreover.com>
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)
+ "\"";

-Michael

-----Original Message-----
From: tedsolr [mailto:tsmith@sciquest.com] 
Sent: Monday, October 06, 2014 10:49 AM
To: solr-user@lucene.apache.org
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: http://lucene.472066.n3.nabble.com/Exact-match-on-string-field-with-special-characters-tp4162209p4162907.html
Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message