3

Solr version 6.1.0

Created a schema with some fields as indexed=true on which I specifically want the solr main-query q to search.

And also added more fields, which I just wanted to select, so marked them as stored=true and indexed=false.

enter image description here

Issue now is that, main query q=India is searching on non-indexed fields like country, which I have specified in the image.

See the result below enter image description here

It is selecting the non-indexed field only when I specify the full value of non-indexed field.

See result for q=Indi enter image description here

How can I restrict solr from searching on non-index fields?

Niranjan Kumar
  • 1,438
  • 1
  • 12
  • 29

1 Answers1

1

According to the screenshot above you're copying the content sent to the field country into the field _text_. When you're not giving Solr a specific field to search (i.e. you're not using one of the dismax handlers with qf or not prefixing your term with the field name field:value), it falls back to the default search field. This is set to _text_ by default. This field is indexed, and since you're copying the content from your country field into the _text_ field, the values from country will give a hit.

If you don't want this to happen, don't copy the content from country into _text_, or give Solr the actual field you want to search.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • I have several fields (not all) on which I need to search the data, as per https://wiki.apache.org/solr/SchemaXml#Common_field_options, the fields can be searchable on if it is marked as indexed=true, then when should I put my key which I want to search on indexed fields, I tried putting it in q (main query) and it doesn't seems to work. – Niranjan Kumar Oct 11 '17 at 06:45
  • As mentioned, you can use `qf` with the (e)dismax handlers (query fields - which fields to query. This allows you to weight the different fields separetly, giving more weight to one field over another - `qf=field1 field2^2` makes field2 twice as important as field1), or you can use a common field like in this case that you copy everything into, then search that field (like in `_text_` in your current schema). Or you can ask for a hit in a specific field using `q=field:value`. – MatsLindh Oct 11 '17 at 07:02