반응형
Recent Posts
Recent Comments
관리 메뉴

개발잡부

[es] payload score 본문

ElasticStack/Elasticsearch

[es] payload score

닉의네임 2022. 2. 20. 22:18
반응형

음.. 이걸 우찌 쓴담..

Setting & Mapping

PUT paylaod_score_query
{
  "mappings": {
    "properties": {
      "color": {
        "type": "text",
        "term_vector": "with_positions_payloads",
        "analyzer": "payload_delimiter"
      }
    }
  },
  "settings": {
    "analysis": {
      "analyzer": {
        "payload_delimiter": {
          "tokenizer": "whitespace",
          "filter": [ "delimited_payload" ]
        }
      }
    }
  }
}

 

데이터 입력 

POST paylaod_score_query/_doc/1
{
  "name" : "T-shirt S",
  "color" : "blue|1 green|2 yellow|3"
}

POST paylaod_score_query/_doc/2
{
  "name" : "T-shirt M",
  "color" : "blue|1 green|2 red|3"
}

POST paylaod_score_query/_doc/3
{
  "name" : "T-shirt XL",
  "color" : "blue|1 yellow|2"
}

쿼리 실행

GET paylaod_score_query/_termvectors/1?fields=color

GET paylaod_score_query/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "name": "t-shirt"
          }
        },
        {
          "span_or": {
            "clauses": [
              {
                "span_term": {
                  "color": "yellow"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

 

 

 

https://github.com/900gle/doo-payload-score

 

GitHub - 900gle/doo-payload-score

Contribute to 900gle/doo-payload-score development by creating an account on GitHub.

github.com

 

반응형

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

[es] _script sort  (0) 2022.04.08
[es] script_fields  (0) 2022.04.08
[es] 자동완성 3  (0) 2022.02.06
[es] 쿼리를 확인해보자  (0) 2022.01.30
[es] 검색쿼리를 만들어 보자 3  (0) 2022.01.30
Comments