term和terms查询(查找zhaoliu这个人的信息)
term query会去倒排索弓|中寻找确切的term,它并不知道分词器的存在。这种查询适合keyword、numeric. date.
term:查询某个字段里含有某个关键词的文档
GET /lib3/user/_search/ { "query":{ "term": {interests": "changge"}}}
terms:查询某个字段里合有多个关键词的文档
GET /ib3/user/_search { "query":{ "terms':{ "interests": ["hejiu","changge']}}
GET /lib3/user/_search
{
"query": {
"term": {
"name": {
"value": "zhaoliu"
}
}
}
}
GET /lib3/user/_search
{
"query": {
"term": {
"name": "zhaoliu"
}
}
}
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "lib3",
"_type" : "user",
"_id" : "1",
"_score" : 0.2876821,
"_source" : {
"name" : "zhaoliu",
"address" : "hei long jiang sheng tie ling shi",
"age" : 50,
"birthday" : "1970-12-12",
"interests" : "xi buan hejiu, duanlian, lvyou"
}
}
]
}
}
查找兴趣爱好interests为hejiu changge的人的信息
GET /lib3/user/_search
{
"query": {
"terms": {
"