Search code examples
c#elasticsearchnestelastic-stack

Can we indexing all the fields in document in Elastic Search


I am a newbie to elastic search. Now I am trying to create a mapping for an index. Dynamic mapping creates the mapping for all the fields in the document. So is there any performance improvement in indexing that only indexing the required properties(Properties that will be used for filtering, sorting, aggregations and full-text search) through explicit mapping in the document.

Thanks, Tamilselvan S.


Solution

  • Explicitly defining mappings for fields helps in the following ways:

    • Mapping a field between, say, Text and String improves the search efficiency since the a field with "Text" is analyzed but with a String is not.
    • Text fields are indexed whereas String fields are not. This impacts the size of the Lucene index and in turn th RAM usage
    • Certain field types like IP when enriched with Geo data need to be stored as with their respective formats like Geo_point, etc. Else heo based aggregations cannot be done.
    • Field types like Integer helps in enabling range based aggregation on the field which eventually helps in aggregation time taken.