好的想法是十分钱一打,真正无价的是能够实现这些想法的人。

关于term query查询的问题

Elasticsearch | 作者 JackDx | 发布于2021年08月17日 | 阅读数:1455

GET ec_chat_message_log/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"delete_time": 0
}
},
{
"term": {
"status": 1
}
},
{
"match_phrase": {
"content.emoji": {
"query": "1231",
"slop": 0
}
}
},
{
"term": {
"type": 1
}
}
]
}
},
"sort": {
"id": {
"order": "desc"
}
},
"from": "1",
"size": "9999",
"highlight": {
"pre_tags": "<font color='red>",
"post_tags": "</font>",
"fields": {
"content.emoji": {}
}
}
}
这样是正常的

74b97a3f1657325884d276845bc207f.png

但是加个条件就查不出了
GET ec_chat_message_log/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"delete_time": 0
}
},
{
"term": {
"status": 1
}
},
{
"match_phrase": {
"content.emoji": {
"query": "1231",
"slop": 0
}
}
},
{
"term": {
"type": 1
}
},
{
"term": {
"to_uid":10016
}
}
]
}
},
"sort": {
"id": {
"order": "desc"
}
},
"from": "1",
"size": "9999",
"highlight": {
"pre_tags": "<font color='red>",
"post_tags": "</font>",
"fields": {
"content.emoji": {}
}
}
}
{
"took" : 294,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}

结构:
{
"ec_chat_message_log" : {
"aliases" : { },
"mappings" : {
"properties" : {
"content" : {
"type" : "text",
"fields" : {
"emoji" : {
"type" : "text",
"analyzer" : "english_emoji"
},
"raw" : {
"type" : "keyword"
}
},
"analyzer" : "charSplit"
},
"create_time" : {
"type" : "integer"
},
"delete_time" : {
"type" : "integer"
},
"extend_info" : {
"type" : "text"
},
"from_uid" : {
"type" : "integer"
},
"guid" : {
"type" : "keyword"
},
"id" : {
"type" : "long"
},
"mark" : {
"type" : "integer"
},
"status" : {
"type" : "integer"
},
"to_uid" : {
"type" : "integer"
},
"type" : {
"type" : "integer"
},
"update_time" : {
"type" : "long"
}
}
},
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"number_of_shards" : "1",
"provided_name" : "ec_chat_message_log",
"creation_date" : "1629172465548",
"analysis" : {
"analyzer" : {
"charSplit" : {
"filter" : [
"lowercase"
],
"char_filter" : [
"html_strip"
],
"type" : "custom",
"tokenizer" : "my_ngram_tokenizer"
},
"english_emoji" : {
"synonyms_path" : "analysis/cldr-emoji-annotation-synonyms-en.txt",
"tokenizer" : "english_with_emoji"
}
},
"tokenizer" : {
"my_ngram_tokenizer" : {
"token_chars" : [
"letter",
"digit",
"punctuation"
],
"min_gram" : "1",
"type" : "ngram",
"max_gram" : "1"
},
"english_with_emoji" : {
"filter" : [
"english_emoji"
],
"min_gram" : "1",
"type" : "ngram",
"max_gram" : "1",
"tokenizer" : "icu_tokenizer"
}
}
},
"number_of_replicas" : "1",
"uuid" : "tKPGlzC5Re-rgywicWd3jg",
"version" : {
"created" : "7140099"
}
}
}
}
}

已邀请:

BetterLevi

赞同来自: lemonzero JackDx

from设置成0看看

要回复问题请先登录注册