尝试更新设置时出错

时间:2013-11-03 21:26:31

标签: elasticsearch

我尝试通过bash脚本执行此命令,但是我收到了这些错误:

#!/bin/bash 

curl -XPOST 'localhost:9200/my_index/_close' 

curl -XPUT 'localhost:9200/my_index/_settings' -d '{ 
 "analysis": { 
    "analyzer": { 
      "ar_analyzer": { 
        "tokenizer": "standard", 
        "filter" : ["standard", "lowercase", "synonym", "ar_stemmer"] 
      }, 
      "fr_analyzer": { 
        "tokenizer": "standard", 
        "filter" : ["standard", "lowercase", "synonym", "fr_stemmer"] 
      } 
    }, 
    "filter" : { 
      "ar_stemmer" : { 
          "type" : "stemmer", 
          "name" : "arabic" 
      }, 
      "fr_stemmer" : { 
          "type" : "stemmer", 
          "name" : "french" 
      }, 
      "synonym" : { 
          "type" : "synonym", 
          "synonyms_path" : "synonyms.txt" 
      } 
    } 
  } 
}' 

curl -XPOST 'localhost:9200/my_index/_open' 

错误堆栈跟踪:

  

{“error”:“IndexPrimaryShardNotAllocatedException [[my_index] primary   没分配帖子   API] “ ”状态“:409} { ”错误“:” ElasticSearchIllegalArgumentException [无法   更新非动态设置[[index.analysis.filter.ar_stemmer.name,   index.analysis.analyzer.fr_analyzer.filter.3,   index.analysis.filter.synonym.type,   index.analysis.analyzer.ar_analyzer.filter.0,   index.analysis.analyzer.fr_analyzer.filter.0,   index.analysis.analyzer.ar_analyzer.filter.1,   index.analysis.analyzer.fr_analyzer.filter.2,   index.analysis.analyzer.fr_analyzer.filter.1,   index.analysis.analyzer.ar_analyzer.filter.2,   index.analysis.analyzer.ar_analyzer.filter.3,   index.analysis.filter.ar_stemmer.type,   index.analysis.filter.fr_stemmer.name,   index.analysis.analyzer.ar_analyzer.tokenizer,   index.analysis.filter.fr_stemmer.type,   index.analysis.analyzer.fr_analyzer.tokenizer,   index.analysis.filter.synonym.synonyms_path]]用于打开   指数[[my_index]]]”, “状态”:400}

3 个答案:

答案 0 :(得分:108)

您好我正在使用这样的设置可能对您有所帮助:

关闭索引

curl -XPOST 'localhost:9200/lookupindex/_close'

更新设置

curl -XPUT 'localhost:9200/lookupindex/_settings' -d '{
    "index": {
        "analysis": {
            "analyzer": {
                "custom_standard_analyzer": {
                    "type": "custom",
                    "tokenizer": "whitespace",
                    "filter": [
                        "lowercase",
                        "asciifolding",
                        "customstopwords"
                    ]
                },
                "phonetic_analyzer": {
                    "type": "custom",
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "asciifolding",
                        "phoneticstopwords"
                    ]
                }
            },
            "filter": {
                "customstopwords": {
                    "type": "stop",
                    "stopwords": [
                        "+",
                        ".",
                        " ",
                        "ca",
                        "fl",
                        "bc",
                        "b.c",
                        "b.c.e",
                        "bce",
                        "act.c.",
                        "act",
                        "style",
                        "style of",
                        "attr.",
                        "attr",
                        "manner of",
                        "manner",
                        "circle of",
                        "circle",
                        "after",
                        "near",
                        "copy",
                        "copy after",
                        "imitator",
                        "school, copy",
                        "studio",
                        "studio of",
                        "Italian school",
                        "workshop of",
                        "workshop",
                        "16th",
                        "or",
                        "17th c.",
                        "late follower",
                        "follower of",
                        "follower",
                        "attributed",
                        "near",
                        "copy after painting",
                        "by or after",
                        "fake",
                        "and school",
                        "workshop-copy",
                        "counterproof",
                        "copy after drawing",
                        "copy of",
                        "school of",
                        "called",
                        "copy IBS",
                        "German School",
                        "placed with",
                        "attribution"
                    ]
                },
                "phoneticstopwords": {
                    "type": "stop",
                    "stopwords": [
                        "+",
                        ",",
                        "-",
                        ".",
                        "ca",
                        "fl",
                        "bc",
                        "b.c",
                        "b.c.e",
                        "bce",
                        "act.c.",
                        "act",
                        "style",
                        "style of",
                        "attr.",
                        "attr",
                        "manner of",
                        "manner",
                        "circle of",
                        "circle",
                        "after",
                        "near",
                        "copy",
                        "copy after",
                        "imitator",
                        "school, copy",
                        "studio",
                        "studio of",
                        "Italian school",
                        "workshop of",
                        "workshop",
                        "16th",
                        "or",
                        "17th c.",
                        "late follower",
                        "follower of",
                        "follower",
                        "attributed",
                        "near",
                        "copy after painting",
                        "by or after",
                        "fake",
                        "and school",
                        "workshop-copy",
                        "counterproof",
                        "copy after drawing",
                        "copy of",
                        "school of",
                        "called",
                        "copy IBS",
                        "German School",
                        "placed with",
                        "attribution"
                    ]
                }
            }
        }
    }
}
'  

完成后重新打开索引

curl -XPOST 'localhost:9200/lookupindex/_open'

答案 1 :(得分:10)

我有类似的例外。你的榜样完整吗?你在关闭之前创建索引吗?

在我的例子中,它是:“创建索引,关闭它,添加设置,添加其他设置,添加映射,打开索引”。索引创建后等待大约1秒修复了异常。

答案 2 :(得分:1)

对于使用AWS Elastic-search服务的人员,不允许关闭和打开,他们需要遵循此处所述的重新索引。

基本上用当前原始索引的所有映射创建一个临时索引,并添加/修改这些映射和设置(分析器所在的位置),删除原始索引并使用该名称创建一个新索引,然后从临时索引复制回所有映射和设置