The ways don't index several fields

My document has fields a,b,c. The field b should be indexed and searchable. The a and c doesn’t need to be searchable. So I think it may save time to index each document by not indexing unnecessary fields such as fields a and c in the example. But I want them to be visible.
Is this the correct mapping setting?

        },
        "a" : {
          "type" : "text",
          "index" : false,
          "norms" : false
        },
        "b" : {
          "type" : "keyword",
          "ignore_above" : 1024
        },
        "c" : {
          "type" : "text",
          "index" : false,
          "norms" : false
        },

I found three different mapping parameters and not sure which is the right one to use.

index: false
index: no
enabled: false

Regards // Hugo

Hi @hugok - I wrote a blog article about this a while back. What you’ve provided above looks correct. This might help clear up your confusion:

The short form is that to intentionally not index a field, you would provide

"index": false

You’ll still be able to retrieve the source of the document if it is returned as a search result, but the field won’t be indexed.

One thing to keep in mind is that if you’re using a dynamic mapping on your index, it will create new mappings when it ingests a field that it hasn’t seen yet. To keep dynamic mappings from growing your indices, you can also use

"dynamic": false

inside of the mappings stanza. If you try to ingest a field for which there is no mapping, an error will take place.

TL:DR; It looks like you’ve done it right to me. Be aware of accidentally adding mappings by ingesting new fields.

Nate

1 Like

Hi @nateynate ,

This is great information. I’m reading your post now.
Thanks for the explanation.

Hugo

1 Like

Just happy to be of service, @hugok! Good luck!