반응형
Recent Posts
Recent Comments
관리 메뉴

개발잡부

[es] _explain 본문

ElasticStack8/Elasticsearch

[es] _explain

닉의네임 2023. 5. 9. 18:19
반응형

자주쓰는 명령어를 모아보잣

#_termvectors
GET hyper-item/_termvectors/1657301588000FA6F960FF6852F49090B7451CB85EC2E?fields=searchItemNm

#_explain
GET hyper-item/_doc/1657301588000FA6F960FF6852F49090B7451CB85EC2E/_explain
{
    "query" :{
    }
}

#_analyze
POST hyper-item/_analyze
{
  "analyzer": "index_analyzer",
  "text": "_마티니로쏘_750ML"
}


POST hyper-item/_analyze
{
  "analyzer": "search_analyzer",
  "text": "과자"
}


POST _analyze
{
  "tokenizer": "standard",
  "filter":  [ "lowercase", "asciifolding" ],
  "text":      "Is this déja vu?"
}

과자를 검색하면 와인이 걸리는 ..

일단 이슈는 상품명이 저렇게 생겼는데 ..

상품명

다양한 뻘짓을 통해 이유는 알아냈지만 

좀 편하게 알아내는 법이 없을까..

 

 

 

 

 

상품명의 텀

{
  "_index" : "hyper-item_2023.05.09.14.57",
  "_type" : "_doc",
  "_id" : "1657301588000FA6F960FF6852F49090B7451CB85EC2E",
  "_version" : 2,
  "found" : true,
  "took" : 0,
  "term_vectors" : {
    "searchItemNm" : {
      "field_statistics" : {
        "sum_doc_freq" : 16173194,
        "doc_count" : 1844854,
        "sum_ttf" : 18146375
      },
      "terms" : {
        "750" : {
          "term_freq" : 1,
          "tokens" : [
            {
              "position" : 5,
              "start_offset" : 15,
              "end_offset" : 18
            }
          ]
        },
        "750ml" : {
          "term_freq" : 1,
          "tokens" : [
            {
              "position" : 6,
              "start_offset" : 15,
              "end_offset" : 20
            }
          ]
        },
        "ml" : {
          "term_freq" : 1,
          "tokens" : [
            {
              "position" : 7,
              "start_offset" : 18,
              "end_offset" : 20
            }
          ]
        },
        "드라이" : {
          "term_freq" : 1,
          "tokens" : [
            {
              "position" : 2,
              "start_offset" : 5,
              "end_offset" : 8
            }
          ]
        },
        "로" : {
          "term_freq" : 1,
          "tokens" : [
            {
              "position" : 1,
              "start_offset" : 3,
              "end_offset" : 4
            }
          ]
        },
        "로쏘" : {
          "term_freq" : 1,
          "tokens" : [
            {
              "position" : 4,
              "start_offset" : 12,
              "end_offset" : 14
            }
          ]
        },
        "비노" : {
          "term_freq" : 1,
          "tokens" : [
            {
              "position" : 3,
              "start_offset" : 9,
              "end_offset" : 11
            }
          ]
        },
        "프레첼" : {
          "term_freq" : 1,
          "tokens" : [
            {
              "position" : 0,
              "start_offset" : 0,
              "end_offset" : 3
            }
          ]
        }
      }
    }
  }
}

쿼리 explain 

GET hyper-item/_doc/1657301588000FA6F960FF6852F49090B7451CB85EC2E/_explain
{
  "query": {
    "bool": {
      "must": [
        {
          "function_score": {
            "query": {
              "multi_match": {
                "query": "과자",
                "fields": [
                  "brandNmEng^1.0",
                  "brandNmKor^1.0",
                  "category.categorySearchKeyword^1.0",
                  "category.dcateNm^1.0",
                  "isbn^1.0",
                  "itemNo^1.0",
                  "itemOptionNms^1.0",
                  "itemStoreInfo.eventInfo.eventKeyword^1.0",
                  "promoKeyword^1.0",
                  "searchItemNm^1.0",
                  "searchKeyword^1.0"
                ],
                "type": "cross_fields",
                "operator": "AND",
                "slop": 0,
                "prefix_length": 0,
                "max_expansions": 50,
                "zero_terms_query": "NONE",
                "auto_generate_synonyms_phrase_query": false,
                "fuzzy_transpositions": true,
                "boost": 1
              }
            },
            "functions": [
              {
                "filter": {
                  "match_all": {
                    "boost": 1
                  }
                },
                "weight": 0
              },
              {
                "filter": {
                  "match_all": {
                    "boost": 1
                  }
                },
                "script_score": {
                  "script": {
                    "source": "category_boost_df",
                    "lang": "boost_script",
                    "params": {
                      "operation_score": 1000,
                      "field": "category.cateCdGroup",
                      "category_id": "200095",
                      "default_score": 1000,
                      "operation_mode": "+"
                    }
                  }
                }
              },
              {
                "filter": {
                  "match_all": {
                    "boost": 1
                  }
                },
                "script_score": {
                  "script": {
                    "source": "category_boost_df",
                    "lang": "boost_script",
                    "params": {
                      "operation_score": 1000,
                      "field": "category.cateCdGroup",
                      "category_id": "300633",
                      "default_score": 1000,
                      "operation_mode": "+"
                    }
                  }
                }
              }
            ],
            "score_mode": "sum",
            "boost_mode": "replace",
            "max_boost": 3.4028235e+38,
            "boost": 1
          }
        }
      ],
      "filter": [
        {
          "range": {
            "saleStartDt": {
              "from": null,
              "to": "now/m",
              "include_lower": true,
              "include_upper": true,
              "boost": 1
            }
          }
        },
        {
          "range": {
            "saleEndDt": {
              "from": "now/m",
              "to": null,
              "include_lower": true,
              "include_upper": true,
              "boost": 1
            }
          }
        },
        {
          "multi_match": {
            "query": "Y",
            "fields": [
              "docDispYn^1.0",
              "rsvDocDispYn^1.0"
            ],
            "type": "best_fields",
            "operator": "OR",
            "slop": 0,
            "prefix_length": 0,
            "max_expansions": 50,
            "zero_terms_query": "NONE",
            "auto_generate_synonyms_phrase_query": true,
            "fuzzy_transpositions": true,
            "boost": 1
          }
        },
        {
          "bool": {
            "should": [
              {
                "terms": {
                  "itemStoreInfo.storeId": [
                    "37",
                    "20163"
                  ],
                  "boost": 1
                }
              },
              {
                "term": {
                  "shipMethod": {
                    "value": "TD_DLV",
                    "boost": 1
                  }
                }
              },
              {
                "term": {
                  "storeType": {
                    "value": "DS",
                    "boost": 1
                  }
                }
              }
            ],
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  }
}

search profiler

explain 결과값

{
  "_index" : "hyper-item_2023.05.09.14.57",
  "_type" : "_doc",
  "_id" : "1657301588000FA6F960FF6852F49090B7451CB85EC2E",
  "matched" : true,
  "explanation" : {
    "value" : 2000.0,
    "description" : "sum of:",
    "details" : [
      {
        "value" : 2000.0,
        "description" : "min of:",
        "details" : [
          {
            "value" : 2000.0,
            "description" : "function score, score mode [sum]",
            "details" : [
              {
                "value" : 0.0,
                "description" : "product of:",
                "details" : [
                  {
                    "value" : 1.0,
                    "description" : "constant score 1.0 - no function provided",
                    "details" : [ ]
                  },
                  {
                    "value" : 0.0,
                    "description" : "weight",
                    "details" : [ ]
                  }
                ]
              },
              {
                "value" : 1000.0,
                "description" : "script score function, computed with script:\"Script{type=inline, lang='boost_script', idOrCode='category_boost_df', options={}, params={operation_mode=+, operation_score=1000, field=category.cateCdGroup, category_id=200095, default_score=1000}}\"",
                "details" : [
                  {
                    "value" : 1.0,
                    "description" : "_score: ",
                    "details" : [
                      {
                        "value" : 1.0,
                        "description" : "max of:",
                        "details" : [
                          {
                            "value" : 1.0,
                            "description" : "(brandNmEng:스낵 | brandNmEng:스넥 | brandNmEng:쿠키 | brandNmEng:비스켓 | brandNmEng:비스킷 | brandNmEng:비스캣 | brandNmEng:프레첼 | brandNmEng:샌드 | brandNmEng:웨하스 | brandNmEng:과자 | brandNmKor:스낵 | brandNmKor:스넥 | brandNmKor:쿠키 | brandNmKor:비스켓 | brandNmKor:비스킷 | brandNmKor:비스캣 | brandNmKor:프레첼 | brandNmKor:샌드 | brandNmKor:웨하스 | brandNmKor:과자 | itemOptionNms:스낵 | itemOptionNms:스넥 | itemOptionNms:쿠키 | itemOptionNms:비스켓 | itemOptionNms:비스킷 | itemOptionNms:비스캣 | itemOptionNms:프레첼 | itemOptionNms:샌드 | itemOptionNms:웨하스 | itemOptionNms:과자 | promoKeyword:스낵 | promoKeyword:스넥 | promoKeyword:쿠키 | promoKeyword:비스켓 | promoKeyword:비스킷 | promoKeyword:비스캣 | promoKeyword:프레첼 | promoKeyword:샌드 | promoKeyword:웨하스 | promoKeyword:과자 | itemStoreInfo.eventInfo.eventKeyword:스낵 | itemStoreInfo.eventInfo.eventKeyword:스넥 | itemStoreInfo.eventInfo.eventKeyword:쿠키 | itemStoreInfo.eventInfo.eventKeyword:비스켓 | itemStoreInfo.eventInfo.eventKeyword:비스킷 | itemStoreInfo.eventInfo.eventKeyword:비스캣 | itemStoreInfo.eventInfo.eventKeyword:프레첼 | itemStoreInfo.eventInfo.eventKeyword:샌드 | itemStoreInfo.eventInfo.eventKeyword:웨하스 | itemStoreInfo.eventInfo.eventKeyword:과자 | searchKeyword:스낵 | searchKeyword:스넥 | searchKeyword:쿠키 | searchKeyword:비스켓 | searchKeyword:비스킷 | searchKeyword:비스캣 | searchKeyword:프레첼 | searchKeyword:샌드 | searchKeyword:웨하스 | searchKeyword:과자 | category.dcateNm:스낵 | category.dcateNm:스넥 | category.dcateNm:쿠키 | category.dcateNm:비스켓 | category.dcateNm:비스킷 | category.dcateNm:비스캣 | category.dcateNm:프레첼 | category.dcateNm:샌드 | category.dcateNm:웨하스 | category.dcateNm:과자 | searchItemNm:스낵 | searchItemNm:스넥 | searchItemNm:쿠키 | searchItemNm:비스켓 | searchItemNm:비스킷 | searchItemNm:비스캣 | searchItemNm:프레첼 | searchItemNm:샌드 | searchItemNm:웨하스 | searchItemNm:과자)",
                            "details" : [ ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "value" : 1000.0,
                "description" : "script score function, computed with script:\"Script{type=inline, lang='boost_script', idOrCode='category_boost_df', options={}, params={operation_mode=+, operation_score=1000, field=category.cateCdGroup, category_id=300633, default_score=1000}}\"",
                "details" : [
                  {
                    "value" : 1.0,
                    "description" : "_score: ",
                    "details" : [
                      {
                        "value" : 1.0,
                        "description" : "max of:",
                        "details" : [
                          {
                            "value" : 1.0,
                            "description" : "(brandNmEng:스낵 | brandNmEng:스넥 | brandNmEng:쿠키 | brandNmEng:비스켓 | brandNmEng:비스킷 | brandNmEng:비스캣 | brandNmEng:프레첼 | brandNmEng:샌드 | brandNmEng:웨하스 | brandNmEng:과자 | brandNmKor:스낵 | brandNmKor:스넥 | brandNmKor:쿠키 | brandNmKor:비스켓 | brandNmKor:비스킷 | brandNmKor:비스캣 | brandNmKor:프레첼 | brandNmKor:샌드 | brandNmKor:웨하스 | brandNmKor:과자 | itemOptionNms:스낵 | itemOptionNms:스넥 | itemOptionNms:쿠키 | itemOptionNms:비스켓 | itemOptionNms:비스킷 | itemOptionNms:비스캣 | itemOptionNms:프레첼 | itemOptionNms:샌드 | itemOptionNms:웨하스 | itemOptionNms:과자 | promoKeyword:스낵 | promoKeyword:스넥 | promoKeyword:쿠키 | promoKeyword:비스켓 | promoKeyword:비스킷 | promoKeyword:비스캣 | promoKeyword:프레첼 | promoKeyword:샌드 | promoKeyword:웨하스 | promoKeyword:과자 | itemStoreInfo.eventInfo.eventKeyword:스낵 | itemStoreInfo.eventInfo.eventKeyword:스넥 | itemStoreInfo.eventInfo.eventKeyword:쿠키 | itemStoreInfo.eventInfo.eventKeyword:비스켓 | itemStoreInfo.eventInfo.eventKeyword:비스킷 | itemStoreInfo.eventInfo.eventKeyword:비스캣 | itemStoreInfo.eventInfo.eventKeyword:프레첼 | itemStoreInfo.eventInfo.eventKeyword:샌드 | itemStoreInfo.eventInfo.eventKeyword:웨하스 | itemStoreInfo.eventInfo.eventKeyword:과자 | searchKeyword:스낵 | searchKeyword:스넥 | searchKeyword:쿠키 | searchKeyword:비스켓 | searchKeyword:비스킷 | searchKeyword:비스캣 | searchKeyword:프레첼 | searchKeyword:샌드 | searchKeyword:웨하스 | searchKeyword:과자 | category.dcateNm:스낵 | category.dcateNm:스넥 | category.dcateNm:쿠키 | category.dcateNm:비스켓 | category.dcateNm:비스킷 | category.dcateNm:비스캣 | category.dcateNm:프레첼 | category.dcateNm:샌드 | category.dcateNm:웨하스 | category.dcateNm:과자 | searchItemNm:스낵 | searchItemNm:스넥 | searchItemNm:쿠키 | searchItemNm:비스켓 | searchItemNm:비스킷 | searchItemNm:비스캣 | searchItemNm:프레첼 | searchItemNm:샌드 | searchItemNm:웨하스 | searchItemNm:과자)",
                            "details" : [ ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "value" : 3.4028235E38,
            "description" : "maxBoost",
            "details" : [ ]
          }
        ]
      },
      {
        "value" : 0.0,
        "description" : "match on required clause, product of:",
        "details" : [
          {
            "value" : 0.0,
            "description" : "# clause",
            "details" : [ ]
          },
          {
            "value" : 1.0,
            "description" : "saleStartDt:[-9223372036854775808 TO 1683622859999]",
            "details" : [ ]
          }
        ]
      },
      {
        "value" : 0.0,
        "description" : "match on required clause, product of:",
        "details" : [
          {
            "value" : 0.0,
            "description" : "# clause",
            "details" : [ ]
          },
          {
            "value" : 1.0,
            "description" : "DocValuesFieldExistsQuery [field=saleEndDt]",
            "details" : [ ]
          }
        ]
      },
      {
        "value" : 0.0,
        "description" : "match on required clause, product of:",
        "details" : [
          {
            "value" : 0.0,
            "description" : "# clause",
            "details" : [ ]
          },
          {
            "value" : 1.0,
            "description" : "(docDispYn:Y | rsvDocDispYn:Y)",
            "details" : [ ]
          }
        ]
      },
      {
        "value" : 0.0,
        "description" : "match on required clause, product of:",
        "details" : [
          {
            "value" : 0.0,
            "description" : "# clause",
            "details" : [ ]
          },
          {
            "value" : 1.0,
            "description" : "ConstantScore(itemStoreInfo.storeId:20163 itemStoreInfo.storeId:37) shipMethod:TD_DLV storeType:DS",
            "details" : [ ]
          }
        ]
      }
    ]
  }
}

 

GET hyper-item/_analyze
{
  "analyzer": "search_analyzer",
  "text": [
    "과자"
  ]
}

반응형

'ElasticStack8 > Elasticsearch' 카테고리의 다른 글

[es8] Elasticsearch Plugin 8.6.2  (0) 2023.05.20
[es8] similarity modules  (0) 2023.05.16
[es8] ignore_malformed  (0) 2023.01.23
[es8] index 와 shard 사이즈  (0) 2022.10.06
[es8] Elasticsearch License  (0) 2022.10.03
Comments