fields(字段)
fields(字段)
curl -XPUT 'localhost:9200/my_index?pretty' -H 'Content-Type: application/json' -d'
{
"mappings": {
"my_type": {
"properties": {
"city": {
"type": "text",
"fields": {
"raw": { #1
"type": "keyword"
}
}
}
}
}
}
}
'
curl -XPUT 'localhost:9200/my_index/my_type/1?pretty' -H 'Content-Type: application/json' -d'
{
"city": "New York"
}
'
curl -XPUT 'localhost:9200/my_index/my_type/2?pretty' -H 'Content-Type: application/json' -d'
{
"city": "York"
}
'
curl -XGET 'localhost:9200/my_index/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"city": "york" #2
}
},
"sort": {
"city.raw": "asc" #3
},
"aggs": {
"Cities": {
"terms": {
"field": "city.raw" #4
}
}
}
}
'Multi-fields with multiple analyzers(多分析器处理多字段)
Last updated