elasticsearch,lumen,Php,Laravel,elasticsearch,Lumen" /> elasticsearch,lumen,Php,Laravel,elasticsearch,Lumen" />

Php 字符串类型的数字格式异常

Php 字符串类型的数字格式异常,php,laravel,elasticsearch,lumen,Php,Laravel,elasticsearch,Lumen,我有一个这样的映射 { "settings": { "analysis": { "filter": { "nGramFilter": { "type": "nGram", "min_gram": 3, "max_gram": 20,

我有一个这样的映射

    {
    "settings": {
            "analysis": {
                "filter": {
                    "nGramFilter": {
                        "type": "nGram",
                        "min_gram": 3,
                        "max_gram": 20,
                        "token_chars": [
                            "letter",
                            "digit",
                            "punctuation",
                            "symbol"
                        ]
                    },
                    "email" : {
                        "type" : "pattern_capture",
                        "preserve_original" : 1,
                        "patterns" : [
                            "([^@]+)",
                            "(\\p{L}+)",
                            "(\\d+)",
                            "@(.+)"
                        ]
                    },
                    "number" : {
                        "type" : "pattern_capture",
                        "preserve_original" : 1,
                        "patterns" : [
                            "([^+-]+)",
                            "(\\d+)"
                        ]
                    },
                    "edgeNGramFilter": {
                        "type": "nGram",
                        "min_gram": 1,
                        "max_gram": 10,
                        "token_chars": [
                            "letter",
                            "digit",
                            "punctuation",
                            "symbol"
                        ]
                    }
                },
                "analyzer": {
                    "nGramAnalyzer": {
                        "type": "custom",
                        "tokenizer": "whitespace",
                        "filter": [
                            "lowercase",
                            "nGramFilter"
                        ]
                    },
                    "whitespaceAnalyzer": {
                        "type": "custom",
                        "tokenizer": "whitespace",
                        "filter": [
                            "lowercase"
                        ]
                    },
                    "email" : {
                       "tokenizer" : "uax_url_email",
                       "filter" : [ 
                            "email", 
                            "lowercase",  
                            "unique" 
                        ]
                    },
                    "number" : {
                       "tokenizer" : "whitespace",
                       "filter" : [ "number", "unique" ]
                    },
                    "edgeNGramAnalyzer": {
                        "type": "custom",
                        "tokenizer": "whitespace",
                        "filter": [
                            "lowercase",
                            "edgeNGramFilter"
                        ]
                    }
                }
            }
        },
    "users": {
        "mappings": {
            "user_profiles": {
                "properties": {
                    "firstName": {
                        "type": "string",
                        "analyzer": "nGramAnalyzer",
                        "search_analyzer": "whitespaceAnalyzer"
                    }, 
                    "lastName": {
                        "type": "string",
                        "analyzer": "nGramAnalyzer",
                        "search_analyzer": "whitespaceAnalyzer"
                    }, 
                    "email": {
                        "type": "string",
                        "analyzer": "email",
                        "search_analyzer": "whitespaceAnalyzer"
                    },
                    "score" : {
                        "type": "string"
                    },
                    "homeLandline": {
                        "type": "string",
                        "analyzer": "number",
                        "search_analyzer": "whitespaceAnalyzer"

                    },
                    "dob": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss"
                    },
                    "mobile": {
                        "type": "integer"
                    },
                    "residenceCity": {
                        "type": "string",
                        "analyzer": "edgeNGramAnalyzer",
                        "search_analyzer": "whitespaceAnalyzer"
                    },
                    "created_at": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss"
                    },
                }
            }
        }
    }
}
我可以得到整数和“NA”的分数,因此我将类型映射为字符串,但在将数据发布到索引时,我得到了数字格式异常

例如:

如果我将第一个数据发布为整数,后跟“NA”。我得到了这些例外

检查日志文件时,我发现以下错误:

[2016-08-29 15:19:01]elasticlog.WARNING:响应[“{\”错误\:“{\”根本原因\:[{\”类型\:“映射程序解析\异常\”,“原因\:\”失败 解析 [score]\“}],\“type\”:\“mapper\u解析\u异常\”,\“reason\”:\“失败” 解析 【分数】\“,\”原因\“:{\”类型\“:\”数字\格式\异常\“,”原因\“:\”用于 输入字符串:\“NH\”\“}},\“status\”:400}][]


您的映射不正确。假设,
users
是索引名,
user\u profiles
是类型:

{
   "users": {
      "mappings": {
         "user_profiles": {
            "properties": {
               "score": {
                  "type": "string"
               }
            }
         }
      }
   }
}

用户配置文件
之前,您缺少一个
映射
,您的映射不正确。假设,
users
是索引名,
user\u profiles
是类型:

{
   "users": {
      "mappings": {
         "user_profiles": {
            "properties": {
               "score": {
                  "type": "string"
               }
            }
         }
      }
   }
}

用户配置文件之前,您缺少一个
映射
,但这不是问题所在。我已经更新了它,忘记添加映射了。您为什么不在原始帖子中提到这一点?请提供用于索引该文档的完整(包括URL)命令。另外,提供
GET/users/\u mapping
的输出。我已经发布了完整的映射。此外,我要求您使用完整(包括URL)命令为失败的文档编制索引。但这不是问题所在。我已经更新了它,忘了添加映射。为什么您在原始帖子中没有提到这一点?提供完整(包括URL)用于为该文档编制索引的命令。另外,提供
GET/users/\u mapping
的输出。我已经发布了完整的映射。此外,我还要求使用完整(包括URL)命令为失败的文档编制索引。