Mustafa Berkan Demir
Mustafa Berkan Demir

Reputation: 133

How to query in string fields in Solr

I've this problem. My query is like this

http://localhost:8983/solr/archiveCore/select?q=strSO:EV11777-01 AND DocType:LLP AND PackName:06 Delivery Documents - MiniPack

The fields(strSO,PackName,DocType) type is string. The fields type was text_general at first. But I have to make them string. Before changing the field types query was working correctly. But when I'm doing it string query response gives me nothing. What's wrong at here? Here my query response

{
  "responseHeader":{
    "status":0,
    "QTime":4,
    "params":{
      "q":"strSO:EV11777-01 AND DocType:LLP AND PackName:06 Delivery Documents - MiniPack"}},
  "response":{"numFound":0,"start":0,"docs":[]
  }}

Upvotes: 0

Views: 1178

Answers (1)

The Bndr
The Bndr

Reputation: 13394

What's wrong at here?

That depends on you field-content. Keep in mind, that fields with type = string are not tokenized!

See the solr docs: https://lucene.apache.org/solr/guide/7_3/field-types-included-with-solr.html (Class StrField)

String (UTF-8 encoded string or Unicode). Strings are intended for small fields and are not tokenized or analyzed in any way. They have a hard limit of slightly less than 32K.

So your query will match an field, only if the field content matches exactly the query content.

For example field content ABC DE will not match an query like ABC DE (one space is missing between the letters at the query)

I recommend using the solr analysis feature from the solr admin page to see, how solr processes your query. You will find this feature at an url like this: http://:8983/solr/#//analysis

Upvotes: 1

Related Questions