Introduction:
In es 2. * version of which is not these two fields, only the string field.
* 5. After, the string field to field in order of date, the introduction of text, keyword field
Well, today we look at, es after 5 *, string type of mapping how should set
Practice:
Preparation:
After es 5. *, string type commonly used three kinds,
1. Default is that we do not set mapping data directly entered, insert
2. We set the mapping to text
3. We set the mapping for the keyword, there will be 2 instead of text keyword
4. We were entered, and add a field name: Zhangsanlisi, respectively, and then look for Joe Smith
Add: Find:
Conclusion one: we found was unable to find the type of keyword can be drawn keyword query word is not supported, but the other two support
5. We continue inside three indexes continue adding names (like adding a few), this time we want to count the number of people of the same name, then we must use the aggregate query
When the query text index, to say no
When the query xuzhan index, to add a keyword in the aggregate field on the line
When a query key, you can
Conclusion 2: text type can not aggregate query
So far we can conclude that these three advantages and disadvantages in the query
Summary
word aggregation
keyword is not supported support
text support is not supported
by default supported by support
at this time you are not thinking about the future that the direct use of default type on the line, everything, but, but, but
After the above test, the type of text can be found at the time of the stored data will be the default word and generate an index. The keyword storing data, it does not index the word, obviously, this division is more data to save memory. For performance reasons, we should consider very carefully what text or keyword?