【问题标题】:Elasticsearch TransportError(400, u'MapperParsingExceptionElasticsearch TransportError(400, u'MapperParsingException
【发布时间】:2015-02-01 22:27:18
【问题描述】:

我已经运行了以下 python 代码,没有任何错误。但现在我有这个

TransportError(400, u'MapperParsingException [Analyzer [whitespace_analyzer] not found for field [job style]]'

代码是:

from elasticsearch import Elasticsearch
import xlrd

es = Elasticsearch()



es.indices.create("we_doing",body={
      'settings': {
        "analysis": {
         "tokenizer":{
            "camel":{
                    "type": "pattern",
                    "pattern":"([^\\\\p{L}\\\\d]+)|(?<=\\\\D)(?=\\\\d)|(?<=\\\\d)(?=\\\\D)|(?<=[\\\\p{L}&&[^\\\\p{Lu}]])(?=\\\\p{Lu})|(?<=\\\\p{Lu})(?=\\\\p{Lu}[\\\\p{L}&&[^\\\\p{Lu}]])"
                }},

     "analyzer": {
        "nGram_analyzer": {
           "type": "custom",
           "tokenizer": ["whitespace","camel"],
           "filter": [
              "lowercase",
              "asciifolding"

           ]
        },
        "whitespace_analyzer": {
           "type": "custom",
           "tokenizer": ["whitespace","camel"],
           "filter": [
              "lowercase",
              "asciifolding"
           ]
        }}}}}, ignore = 400 ) 

mapping = {
"we_data": {

    "properties": {
        "job id": {"type": "string", "index": "not_analyzed"},

        "job style":{
        "type":"string",

        "index_analyzer": "nGram_analyzer",
        "search_analyzer": 'whitespace_analyzer',


    },

        "location": {"type": "string", "index": "not_analyzed"},
        "experience": {"type": "string", "index": "not_analyzed"},
        "post date": {"type": "string", "index": "not_analyzed"},
        "job description": {"type": "string", "index": "not_analyzed"},

    }}}


es.indices.put_mapping(index="we_doing", doc_type="we_data", body=mapping)

它运行良好。现在我遇到了很多麻烦。它将在 2 天内上线。请提供一些帮助。

【问题讨论】:

  • 你做了什么让它不工作?这类问题不会单独发生。他们需要人类的帮助!
  • 在我的记忆中我什么都没做。如果我指定标准分析器,它正在工作。为什么不采用自定义分析仪???请帮忙。
  • 您是否尝试使用 curl 命令发送原始 json 映射?
  • 不,我已将其修改为正确的 json 格式和相应的字段名称

标签: python indexing elasticsearch lucene


【解决方案1】:

分析器只能使用一个标记器(根据Elasticsearch Analysis reference page)。您需要使用 TokenFilter 来代替其中一个(Word Delimiter Token Filter 应该很好),或者使用同时完成两者的 Tokenizer。

【讨论】:

    猜你喜欢
    • 2017-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-21
    • 1970-01-01
    • 2019-04-17
    相关资源
    最近更新 更多