2016-05-26 3 views
1

私はマッピングにストップワードのリストを追加しようとしていますが、エラーが発生します。これはマッピングです:elasticsearchを使用してアナライザにストップワードリストを定義します。

PUT test-recipe 
{ 
    "mappings": { 
    "recipe" : { 
     "properties" : { 
     "ingredients" : { 
      "type" : "string", 
      "analyzer": "english", 
      "stopwords": ["my", "stop", "words"] 
     } 
     } 
    } 
    } 
} 

このマッピングは、ストップワードパラメータなしで正常に動作します。しかし、ストップワードフィールドでは、次のエラーが表示されます。

{ 
    "error": { 
     "root_cause": [ 
     { 
      "type": "mapper_parsing_exception", 
      "reason": "Mapping definition for [ingredients] has unsupported parameters: [stopwords : [Best®, Halves, organic, island, free, gluten, high-gluten, segments, baking, cooking, new, active, dry, leaves, slices, sliced, warm, root, hot, jack, extract, slivered, sliver, non-fat, fat, chopped, skinless, seed, nonfat, melted, cracked, in, split, vegetable, smoked, medium, nectar, all-purpose, fraîche, fresh]]" 
     } 
     ], 
     "type": "mapper_parsing_exception", 
     "reason": "Failed to parse mapping [recipe]: Mapping definition for [ingredients] has unsupported parameters: [stopwords : [Best®, Halves, organic, island, free, gluten, high-gluten, segments, baking, cooking, new, active, dry, leaves, slices, sliced, warm, root, hot, jack, extract, slivered, sliver, non-fat, fat, chopped, skinless, seed, nonfat, melted, cracked, in, split, vegetable, smoked, medium, nectar, all-purpose, fraîche, fresh]]", 
     "caused_by": { 
     "type": "mapper_parsing_exception", 
     "reason": "Mapping definition for [ingredients] has unsupported parameters: [stopwords : [Best®, Halves, organic, island, free, gluten, high-gluten, segments, baking, cooking, new, active, dry, leaves, slices, sliced, warm, root, hot, jack, extract, slivered, sliver, non-fat, fat, chopped, skinless, seed, nonfat, melted, cracked, in, split, vegetable, smoked, medium, nectar, all-purpose, fraîche, fresh]]" 
     } 
    }, 
    "status": 400 
} 

なぜこの問題が発生したのか分かりましたら、私はその日を迎えます。さらに、私の「このようなクエリのように」をやっているときにストップワードリストが考慮に入れられるでしょうか?

答えて

1

あなたはストップワードのフィルタを作成して、私は次のエラーを持っているあなたのアナライザで

#remove index 
#DELETE recipe 

#put mapping, analyzer and filter for stop words 
PUT recipe 
{ 
    "settings": { 
    "analysis": { 
     "analyzer": { 
     "cooking_nonstop": { 
      "type": "custom", 
      "tokenizer": "standard", 
      "filter": [ 
      "lowercase", 
      "english_morphology", 
      "my_stopwords" 
      ] 
     } 
     }, 
     "filter": { 
      "my_stopwords": { 
      "type": "stop", 
      "stopwords": "Best®,Halves,organic,island,free,gluten,high-gluten,segments,baking,cooking,new,active,dry,leaves,slices,sliced,warm,root,hot,jack,extract,slivered,sliver,non-fat,fat,chopped,skinless,seed,nonfat,melted,cracked,in,split,vegetable,smoked,medium,nectar,all-purpose,fraîche,fresh" 
      } 
     } 
     } 
    }, 
    "mappings": { 
     "recipe": { 
     "properties": { 
      "ingredients": { 
      "type": "string", 
      "analyzer": "cooking_nonstop" 
      } 
     } 
     } 
    } 
    } 

#check analyzer 
GET /recipe/_analyze?analyzer=cooking_nonstop&text=put+fresh+egs+in+hot+water 

#create document 
POST recipe/recipe/boiled_egs 
{ 
    "ingredients":"put fresh egs in hot water" 
} 

#another stop word filter demonstration 
POST recipe/_search 
{ 
    "aggs": { 
    "terms": { 
     "terms": { 
     "field": "ingredients", 
     "size": 10 
     } 
    } 
    } 
} 
+0

をそれを使用する必要があります:カスタムAnalyzerは、[cooking_nonstop]の名前でフィルタを見つけることができませんでした[english_morphology] – mel

+0

あなたは右、単に "cooking_nonstop"アナライザーから削除するか、[ここ](https://github.com/imotov/elasticsearch-analysis-morphology)からインストールしてください。私はコピー/貼り付けの問題です=) – pkhlop

関連する問題