Loredra L
Loredra L

Reputation: 1553

Solr query- How to remove all special-characters logical interpretation?

This is slightly different than remove all special character from input String. I just want them as-it-is. For example:

Query: Haha AND LaLa would be tokenized as

1. Haha
2. And
3. LaLa

not

1. Haha
2. LaLa

and with the same logic, a single input of special character such as:

`! , . : ; OR NOT < >` 

would be...themselves (Not logical constructor and the query would return result if in database there are names like that exist)

Upvotes: 0

Views: 446

Answers (1)

Sanjay Dutt
Sanjay Dutt

Reputation: 2222

You can use field or raw query parser they search for the query string that you have typed without any analysis or transformation.

q = {!field f='title'} Haha AND LaLa

[Debug-Response]

<lst name="debug">
<str name="rawquerystring">{!field f='title'}Haha AND LaLa</str>
<str name="querystring">{!field f='title'}Haha AND LaLa</str>
<str name="parsedquery">title:Haha AND LaLa</str>
<str name="parsedquery_toString">title:Haha AND LaLa</str>
<str name="QParser"/>
</lst>

As you can see from the response Solr Looking for the document which contains "Haha AND LaLa". Field query parser treats "AND" as search keyword not as Logical operator.

Upvotes: 1

Related Questions