Reputation: 3
In Elasticsearch 7, consider these three mappings:
"properties" : {
"actors" : {
"type" : "text",
"fields" : {"keyword" : {"type" : "keyword","ignore_above" : 25}}
},
and
"properties" : {
"actors" : {
"type" : "text",
"fields" : {"raw" : {"type" : "keyword","ignore_above" : 25}}
},
and
"properties" : {
"actors" : {
"type" : "text",
"fields" : {"custom_field" : {"type" : "keyword","ignore_above" : 25}}
},
What is the difference between
Upvotes: 0
Views: 2114
Reputation: 196
They are just preference: https://www.elastic.co/guide/en/elasticsearch/reference/8.8/multi-fields.html
FYI, ElasticSearch version >= 5 have two string types:
From your example: actors is text type. Then by default it will perform full-text-search. If you want to do exact-match search on this field, you will need to custom your parameters by adding either keyword, raw, custom_field at the end.
Example:
# There are records
{
actors: "hello world"
},
{
actors: "hello mom"
}
Default search will perform full-text search:
GET products/_search
{
"query": {
"match": {
"actors": "hello"
}
}
}
actors: "hello" => will return 2 above records.
If you want to perform keyword search (exact match) then we need to custom your parameter as the following:
#1
GET products/_search
{
"query": {
"match": {
"actors.keyword": "hello"
}
}
}
#2
GET products/_search
{
"query": {
"match": {
"actors.raw": "hello"
}
}
}
#3
GET products/_search
{
"query": {
"match": {
"actors.custom_field": "hello"
}
}
}
Upvotes: 0
Reputation: 9099
They are same. They are just three fields with type as keyword, having different names
Upvotes: 1