问题
I have data and and i want to create index and want it to make searchable and aggregatable both.If I use datatype keyword I can't search any string but can aggregate but if I use datatype text then I can't aggregate but can search any string. So please tell me how to resolve this problem. I am using elasticsearch 6
回答1:
The solution is to create a text
field with a keyword
sub-field so that you can do both, search text and aggregate values:
Your field mapping should look like this:
{
"my_field": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
Using the above mapping, you can search on the my_field
field and aggregate and my_field.keyword
.
来源:https://stackoverflow.com/questions/51531760/elasticsearch-datatype-keyword-make-it-searchable