2021年5月5日星期三

"must_not" part of Elasticsearch does not work normally

I want to only look up search terms that are included only in "feed_content" and "feed_title", but all fields contain the words I searched for, so they are all lookups at once. I don't know if the "must_not" part doesn't work or if the "multi_match" part doesn't work.. and use seunjeon Please help me.

GET ohing_feed_v2/_search?q="퇴근"  {    "query" : {      "bool": {        "must": [          {            "multi_match" : {              "type" : "phrase_prefix",               "query": "_searchParams",              "max_expansions": 5,              "fields" : [                "feed_content", "feed_title"              ],              "operator": "and"            }          }        ],        "must_not": [          {            "match": {              "tag_list" : "_searchParams"            }          }        ]      }    },    "sort": [      {        "reg_dt_unix": {          "order": "desc"        }      }    ]  }  

index

PUT /ohing_feed_v2  {    "settings": {      "index" : {        "analysis" : {          "analyzer" : {            "korean" : {              "type" : "custom",              "tokenizer" : "seunjeon_tokenizer",              "char_filter" : ["lowercase"]            }          },          "char_filter" : {            "lowercase" : {              "type" : "mapping",              "mappings" : [                "+ => _plus_",                "~ => _tilde_",                "! => _exclamation_",                "? => _question_",                "- => _minus_",                 "= => _equal_",                "$ => _dollar_",                "@ => _at_",                 "% => _percentage_",                "^ => _caret_",                "& => _ampersand_",                "* => _asterisk_",                "[ => _openbracket_",                "] => _closebrackets_",                "{ => _openbraces_",                "} => _closebraces_",                "( => _openparentheses_",                ") => _closeparentheses_",                "< => _lessthansign_",                "> => _greaterthansign",                ": => _colon_",                "; => _semicolon_",                ", => _comma_",                ". => _period_",                "/ => _slash_",                "# => _hash_",                "_ => _underscore_"              ]            }          },          "tokenizer" : {            "seunjoen_tokenizer" : {              "type" : "seunjeon_tokenizer",              "index_eojeol" : true,              "index_poses" : [                "UNK",                "EP",                "E",                "I",                "J",                "M",                "N",                "S",                "SL",                "SH",                "SN",                "V",                "VCP",                "XP",                "XS",                "XR"              ]            }          }        }      }    },     "mappings": {      "properties": {        "@timestamp" : {          "type": "date"        },        "anony_yn" : {          "type": "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "category_cd" : {          "type" : "text",          "fields" : {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "category_nm" : {          "type": "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "cmmt_cnt" : {          "type" : "long"        },        "content_char_cnt" : {          "type" : "long"        },        "content_line_cnt" : {          "type" : "long"        },        "feed_content" : {          "type" : "text",          "analyzer": "korean"        },        "feed_id" : {          "type" : "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "feed_title" : {          "type": "text",          "analyzer": "korean"        },        "feed_type_cd" : {          "type" : "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "like_cnt" : {          "type" : "long"        },        "online_update_dt" : {          "type" : "date"        },        "profile_image_url" : {          "type" : "text",          "fields" : {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "profile_open_type_cd" : {          "type" : "text",          "fields" : {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "ref_feed_cnt" : {          "type" : "long"        },        "ref_feed_id" : {          "type" : "text",          "fields" : {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "reg_dt" : {          "type" : "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "reg_dt_unix" : {          "type" : "long"        },        "reg_user_id" : {          "type" : "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "tag_list" : {          "type" : "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "user_login_id" : {          "type" : "text",           "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "user_nm" : {          "type" : "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "user_real_nm" : {          "type" : "text",          "fields": {            "keyword" : {              "type" : "keyword",              "ignore_above" : 256            }          }        },        "view_cnt" : {          "type" : "long"        }      }    }  }  

and sample date result

{    "took" : 10,    "timed_out" : false,    "_shards" : {      "total" : 5,      "successful" : 5,      "skipped" : 0,      "failed" : 0    },    "hits" : {      "total" : {        "value" : 6,        "relation" : "eq"      },      "max_score" : null,      "hits" : [        {          "_index" : "ohing_feed_v2",          "_type" : "_doc",          "_id" : "FEED_00000006556",          "_score" : null,          "_source" : {            "category_cd" : null,            "profile_image_url" : "876411AF-FB67-4324-A4F9.jpg",            "user_real_nm" : "정안",            "user_login_id" : "111ss33",            "ref_feed_id" : "",            "online_update_dt" : "2021-05-04T05:27:52.000Z",            "feed_title" : null,            "view_cnt" : null,            "feed_content" : "퇴근",            "reg_dt" : "2021-05-03 16:28:47",            "reg_user_id" : "USR_00000000528",            "profile_open_type_cd" : "OPEN",            "cmmt_cnt" : 0,            "ref_feed_cnt" : 0,            "like_cnt" : 0,            "content_char_cnt" : 153,            "@timestamp" : "2021-05-04T05:41:00.764Z",            "user_nm" : "정안짱",            "reg_dt_unix" : 1620026927,            "anony_yn" : "N",            "feed_id" : "FEED_000000006556",            "category_nm" : null,            "tag_list" : "#테스트",            "feed_type_cd" : "FEED",            "content_line_cnt" : 1          },          "sort" : [            1620026927          ]        }  
https://stackoverflow.com/questions/67382099/must-not-part-of-elasticsearch-does-not-work-normally May 04, 2021 at 05:27PM

没有评论:

发表评论