Nelze vytvořit vlastní analyzátor elaticsearch

0

Otázka

Snažím se vytvořit vlastní analyzátor v elasticsearch. zde je analyzátor

{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer" : "standard",
          "filter" : ["custom_stopper", "custom_stems", "custom_synonyms"]
        },
        "filter" : {
            "custom_stopper" : {
                "type" : "stop",
                "stopwords_path" : "analyze/stopwords.txt"
            },
            "custom_stems" : {
                "type" : "stemmer_override",
                "rules_path" : "analyze/stem.txt"
            },
            "custom_synonyms" : {
                "type" : "synonyms",
                "synonyms_path" : "analyze/synonym.txt"

            }
        }
        }
      }
    }
  }

ale to házet chybu

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "analyzer [filter] must specify either an analyzer type, or a tokenizer"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "analyzer [filter] must specify either an analyzer type, or a tokenizer"
    },
    "status": 400
}

Co dělám špatně?

elasticsearch kibana
2021-11-23 13:06:23
1

Nejlepší odpověď

1

Na filter musí být na stejné úrovni s analyzer.

Struktura vypadá nějak takhle:

{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "standard",
          "char_filter": [
            "custom_stopper",
            "custom_stems",
            "custom_synonyms"
          ]
        }
      },
      "filter": {
        "custom_stopper": {
          "type": "stop",
          "stopwords_path": "analyze/stopwords.txt"
        },
        "custom_stems": {
          "type": "stemmer_override",
          "rules_path": "analyze/stem.txt"
        },
        "custom_synonyms": {
          "type": "synonyms",
          "synonyms_path": "analyze/synonym.txt"
        }
      }
    }
  }
}
2021-11-23 13:20:28

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................