先說(shuō)結(jié)論:
term、terms只作用于keyword類型字段,不作用text類型(要使用match查詢);
term、terms都代表字段全等匹配,意思是搜索詞和命中詞是完全等匹,不是包含關(guān)系;
1、創(chuàng)建索引
person_name設(shè)置為keyword;query_name設(shè)置為text分詞;
{
"person" : {
"mappings" : {
"dynamic_templates" : [
{
"message_full" : {
"match" : "message_full",
"mapping" : {
"fields" : {
"keyword" : {
"ignore_above" : 2048,
"type" : "keyword"
}
},
"type" : "text"
}
}
},
{
"message" : {
"match" : "message",
"mapping" : {
"type" : "text"
}
}
},
{
"strings" : {
"match_mapping_type" : "string",
"mapping" : {
"type" : "keyword"
}
}
}
],
"properties" : {
"person_name" : {
"type" : "keyword"
},
"query_name" : {
"type" : "text",
"analyzer" : "standard"
}
}
}
}
}
查詢1文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-557829.html
GET person/_count
{
"query": {
"term": {
"person_name": {
"value": "Devin Gagon"
}
}
}
}
返回結(jié)果,命中三條
{
"count" : 3
}
查詢2?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-557829.html
GET person/_count
{
"query": {
"term": {
"query_name": {
"value": "Devin Gagon"
}
}
}
}
查詢結(jié)果
{
"count" : 0
}
到了這里,關(guān)于ES term terms 查詢的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!