Reputation: 4225
Considering a simple table:
CREATE TABLE transactions (
enterprise_id uuid,
transaction_id text,
state text,
PRIMARY KEY ((enterprise_id, transaction_id))
and Solr core with default, auto-generated parameters.
How do I construct a Solr query that will find me record(s) in this table that have state
value exact match to an input, considering the state
can be arbitrary string?
I tried this with state value of a+b
. This works fine with q=state:"a+b"
, but that creates a "phrase query":
"rawquerystring": "state:\"a+b\"",
"querystring": "state:\"a+b\"",
"parsedquery": "PhraseQuery(state:\"a b\")",
"parsedquery_toString": "state:\"a b\"",
So, the same record is found if I use query like q=state:"a(b"
, which results into the same phrased query and finds the record with state
of a+b
. That is unacceptable to me, because I need an exact match.
I went through https://cwiki.apache.org/confluence/display/solr/Other+Parsers, and tried using q={!term f=state}a+b
or q={!raw f=state}a+b
, but neither even finds my sample transaction record.
Upvotes: 0
Views: 180
Reputation: 734
Probably you got state
generated as a TextField
where standard tokenization is applied StandardTokenizer and then a split is made on +
and the plus sign itself is discarded. You could use a different tokenizer (whitespace?) or just make state an StrField
for an exact match.
This works for me with state
as an StrField
:
select * from transactions where solr_query='state:a+b';
Upvotes: 1