前言
本文基于elasticsearch7.3.0版本
实例
# 创建索引
PUT my_index
{
"mappings": {
"properties": {
"company":{
"type": "keyword"
}
}
}
}
# 添加数据
PUT my_index/_doc/1
{
"company":"alibaba"
}
# 添加数据
PUT my_index/_doc/2
{
"company":["baidu","tengxun"]
}
简单查询
GET my_index/_search
{
"query": {
"term": {
"company": {
"value": "baidu"
}
}
}
}
# 响应
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 0.8025915,
"hits" : [
{
"_index" : "my_index",
"_type" : "_doc",
"_id"