We're relatively new to ES and discovered that after indexing some data, fields that are of type text now have a sub-field 'keyword' of type 'keyword'. Is this there to allow aggregation or other searches that are not allowed on text fields?
If so, and if we are starting our project from scratch, is it advisable to go this route so we can either do full text queries on the field, or keyword queries on the .keyword field...or should we make our field of type keyword to begin with? We are honestly not sure whether we will do stem-like queries on the field, so we'd like to be able to do either type of query. Thanks
Is this there to allow aggregation or other searches that are not allowed on text fields?
Yes. Aggs and Sorting most of the time.
Basically if you want to run full text search on a field where scoring is important for example, or using fuzzy queries, then use a text field.
If you need to compute aggs or do sorting, use keyword.
If you need to do both, do like elasticsearch is doing by default:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.