반응형
Recent Posts
Recent Comments
관리 메뉴

개발잡부

[es] sort - payload sort 3 본문

ElasticStack/Elasticsearch

[es] sort - payload sort 3

닉의네임 2022. 8. 11. 16:20
반응형

payload sort 2 는 어떻게 됐는지.. 모르겠네..

왜 작성하다 말았지..

 

https://ldh-6019.tistory.com/270

 

[es] payload-score 7.15.1 gradle

payload score plugin 을 만들어 보자 https://www.elastic.co/guide/en/elasticsearch/reference/7.15/analysis-delimited-payload-tokenfilter.html#analysis-delimited-payload-tokenfilter java 11 elasticsea..

ldh-6019.tistory.com

일단 여기 플러그인 만들어 놓았고

 

아래는 회사에서 쓰는거로 테스트 

집에가서 섞어봐야지

encoding (Optional, string) Data type for the stored payload. Valid values are:

float(Default) Float

identity Characters

int Integer

 

PUT edlp
{
  "settings": {
    "index": {
      "search": {
        "slowlog": {
          "threshold": {
            "fetch": {
              "warn": "3s"
            },
            "query": {
              "warn": "3s"
            }
          }
        }
      },
      "refresh_interval": "5s",
      "number_of_shards": "3",
      "analysis": {
      
        "char_filter": {
          "normalize_char_filter": {
            "type": "mapping",
            "mappings": [
              """\u0020 => """
            ]
          }
        },
    
        "analyzer": {
          "payload_delimiter": {
            "filter": [
              "delimited_payload"
            ],
            "encoding": "int",
            "delimiter": "|",
            "tokenizer": "whitespace"
          },
          "category_keyword_analyzer": {
            "filter": [
              "trim",
              "lowercase"
            ],
            "char_filter": [
              "normalize_char_filter"
            ],
            "type": "custom",
            "tokenizer": "standard"
          }

        }
      },
      "number_of_replicas": "1"
    }
  },
  "mappings": {
    "dynamic": "false",
    "properties": {
      "orderName": {
        "type": "keyword"
      },
      "edlpInfo": {
        "type": "text",
        "term_vector": "with_positions_payloads",
        "analyzer": "payload_delimiter"
      }
    }
  }
}
POST _bulk?refresh
{"index":{"_index":"edlp","_id":"1"}}
{"orderName":"data1","edlpInfo":"감자|1"}
{"index":{"_index":"edlp","_id":"2"}}
{"orderName":"data2","edlpInfo":"감자|10"}
{"index":{"_index":"edlp","_id":"3"}}
{"orderName":"data3","edlpInfo":"감자|9"}
{"index":{"_index":"edlp","_id":"4"}}
{"orderName":"data4","edlpInfo":"감자|8"}
{"index":{"_index":"edlp","_id":"5"}}
{"orderName":"data5","edlpInfo":"감자|7"}
{"index":{"_index":"edlp","_id":"6"}}
{"orderName":"data6","edlpInfo":"감자|6"}
{"index":{"_index":"edlp","_id":"7"}}
{"orderName":"data7","edlpInfo":"감자|5"}
{"index":{"_index":"edlp","_id":"8"}}
{"orderName":"data8","edlpInfo":"감자|4"}
{"index":{"_index":"edlp","_id":"9"}}
{"orderName":"data9","edlpInfo":"감자|3"}
{"index":{"_index":"edlp","_id":"10"}}
{"orderName":"data10","edlpInfo":"감자|2"}
GET edlp/_search
{
  "query": {
    "match_all": {}
  },
  "sort": [
    {
      "_script": {
        "script": {
          "source": "payload_sort",
          "lang": "sort_script",
          "params": {
            "field": "edlpInfo",
            "value": "감자"
          }
        },
        "type": "number",
        "order": "asc"
      }
    }
  ]
}

 

{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 3,
    "successful" : 3,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : null,
        "_source" : {
          "orderName" : "data1",
          "edlpInfo" : "감자|1"
        },
        "sort" : [
          1.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "10",
        "_score" : null,
        "_source" : {
          "orderName" : "data10",
          "edlpInfo" : "감자|2"
        },
        "sort" : [
          2.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "9",
        "_score" : null,
        "_source" : {
          "orderName" : "data9",
          "edlpInfo" : "감자|3"
        },
        "sort" : [
          3.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "8",
        "_score" : null,
        "_source" : {
          "orderName" : "data8",
          "edlpInfo" : "감자|4"
        },
        "sort" : [
          4.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "7",
        "_score" : null,
        "_source" : {
          "orderName" : "data7",
          "edlpInfo" : "감자|5"
        },
        "sort" : [
          5.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "6",
        "_score" : null,
        "_source" : {
          "orderName" : "data6",
          "edlpInfo" : "감자|6"
        },
        "sort" : [
          6.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "5",
        "_score" : null,
        "_source" : {
          "orderName" : "data5",
          "edlpInfo" : "감자|7"
        },
        "sort" : [
          7.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "4",
        "_score" : null,
        "_source" : {
          "orderName" : "data4",
          "edlpInfo" : "감자|8"
        },
        "sort" : [
          8.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : null,
        "_source" : {
          "orderName" : "data3",
          "edlpInfo" : "감자|9"
        },
        "sort" : [
          9.0
        ]
      },
      {
        "_index" : "edlp",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : null,
        "_source" : {
          "orderName" : "data2",
          "edlpInfo" : "감자|10"
        },
        "sort" : [
          10.0
        ]
      }
    ]
  }
}
반응형

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

[es] Terms Query  (0) 2022.09.27
[es] ESSingleNodeTestCase  (0) 2022.08.14
[es] aggregation test 4  (0) 2022.07.20
[es] _update_by_query  (0) 2022.07.20
[es] aggregation test 3  (0) 2022.07.19
Comments