Umair Ayub
Umair Ayub

Reputation: 21351

How to search a phrase in a text field in SOLR?

I have this field in my SOLR database.

enter image description here

I want to pull all records which have entire word North Korea in nk_title field.

After reading SOLR Docs, I have tried

nk_title:*North Korea*

But it gives me error

  "error": {
    "msg": "undefined field text",
    "code": 400
  }

I have tried

nk_title:"North Korea"

But it gives me only results like

Talk about "Threat from North Korea" Problems
Deceptive Theory of "Threat from North Korea"

Means that returns results which have word North Korea with double-quotes around it.

Upvotes: 0

Views: 198

Answers (1)

The Bndr
The Bndr

Reputation: 13394

1st) It seams there is an configuration error in your solr config/schema. Somewhere you have used an filed with the name text, but you have never defined an field with that name. Keep in mind, that text is ordinary an default FieldType, not an field name.

2nd)

Means that returns results which have word North Korea with double-quotes around it.

If the shown behavior is correct or not depends on your setting. Take a look at your schema.xml, how the nk_title is tokenized. It also depends on your search-handler settings. If you use an standard tokenizer (including split on whitespaces) and your search handler does an AND for all search therms, so you will also find the following string: South Korea different from North Canada

Upvotes: 1

Related Questions