본문 바로가기

Elasticsearch

[Elasticsearch] analyzer [ ] contains filters [ ] that are not allowed to run in index time mode

반응형

ERROR : "analyzer [analyzer_name] contains filters [synonyms_name] that are not allowed to run in index time mode."

 

위와 같은 에러가 나와서 찾아보니 동의어 txt 추가 할 때 updateable:true 를 주어서 에러가 난 것이었다. 이걸 지워주니 에러가 안나도 index가 잘 생성되었다. 

 

 

PUT keyword_test_v1
{
    "mappings" : {
      "properties" : {
        "tag" : {
          "type" : "text",
          "fields": {
            "nori": {
              "search_analyzer":"standard",
              "analyzer": "nori_mixed_analyzer",
              "type": "text"
            },
            "ngram": {
              "analyzer": "ngram_analyzer",
              "type": "text"
            },
            "keyword": {
              "type": "keyword"
            },
            "synonyms": {
              "type": "text",
              "analyzer": "synonym_analyzer"
            }
          }
        },
        "location" : {
          "properties" : {
            "coordinates" : {
              "type" : "geo_point"
            },
            "type" : {
              "type" : "keyword"
            }
          }
        },
        "radius": {
          "type": "long"
        }
      }
    },
    "settings" : {
      "index" : {
        "analysis" : {
          "analyzer" : {
            "ngram_analyzer" : {
              "type": "custom",
              "tokenizer" : "ngram_tokenizer"
            },
            "nori_mixed_analyzer" : {
              "tokenizer" : "nori_mixed_tokenizer"
            },
            "synonym_analyzer": {
              "tokenizer": "whitespace",
              "filter": ["keyword_synonyms"]
            }
          },
          "filter": {
            "keyword_synonyms": {
              "type": "synonym",
              "synonyms_path": "recommendation_keyword_synonyms.txt",
              // "updateable": true <- 이게 없어야 에러가 안남
            }
          },
          "tokenizer" : {
            "ngram_tokenizer" : {
              "type" : "ngram",
              "min_gram" : "1",
              "max_gram" : "2",
              "token_chars":[
                "letter",
                "digit"
              ]
            },
            "nori_mixed_tokenizer" : {
              "type" : "nori_tokenizer",
              "decompound_mode" : "mixed"
            }
          }
        }
      }
    }
}

 

"updateable": true 가 없어야 에러가 안나고 index가 잘 생성된다. 

 

변할 수 있는 동의어 파일을 허락하지 않는 이유 (at index time) 는 여러번 변경된 동의어에 대해 혼란스러운 검색이 될 수 있기 때문이다. 

 

 

 

 

 

Reference : https://discuss.elastic.co/t/synonyms-filter-doesnt-work-in-all-modes-when-indexing/223071

반응형