更新Elasticsearch中现有索引的映射

时间:2018-11-13 13:31:22

标签: elasticsearch

我对弹性搜索完全陌生。因此,如果这是一个愚蠢的问题,请原谅我,而我的问题可能已经在其他地方回答了,但我找不到它。 我想将Elastic Search用作网络中PDF和docx的搜索引擎。我使用fscrawler提取PDF以进行弹性搜索。由于我要提取的文档使用多种语言,因此我想使用n-graming来词干。为此,我想像这样更新我的映射

PUT test/_mappings/_all
{
"mappings": {
    "title": {
      "properties": {
        "title": {
          "type": "text",
          "fields": {
            "de": {
              "type":     "string",
              "analyzer": "german"
            },
            "en": {
              "type":     "string",
              "analyzer": "english"
            },
             "general": { 
              "type":     "string",
              "analyzer": "trigrams"
          }
        }
      }
    }
  }
}
}

现在我收到此错误消息

  

{“错误”:{       “根本原因”: [         {           “ type”:“ mapper_parsing_exception”,           “ reason”:“根映射定义具有不受支持的参数:[映射:{title = {properties = {title = {type = text,   字段= {de = {类型=字符串,分析器=德语},en = {类型=字符串,   Analyzer = english},general = {type = string,analyzer = trigrams}}}}}}]]“         }       ],       “ type”:“ mapper_parsing_exception”,       “ reason”:“根映射定义具有不受支持的参数:[映射:{title = {properties = {title = {type = text,   字段= {de = {类型=字符串,分析器=德语},en = {类型=字符串,   Analyzer = english},general = {type = string,analyzer = trigrams}}}}}}]“”
  },“状态”:400}

您是否知道我该如何解决?还是您有一个主意,如何在不使用fscrawler的情况下提取具有正确映射的文件?

2 个答案:

答案 0 :(得分:0)

这些是我的设置

    {
  "test": {
    "settings": {
      "index": {
        "mapping": {
          "total_fields": {
            "limit": "2000"
          }
        },
        "number_of_shards": "5",
        "provided_name": "test",
        "creation_date": "1542031632596",
        "analysis": {
          "filter": {
            "trigrams_filter": {
              "type": "ngram",
              "min_gram": "3",
              "max_gram": "3"
            }
          },
          "analyzer": {
            "fscrawler_path": {
              "tokenizer": "fscrawler_path"
            },
            "trigrams": {
              "filter": [
                "lowercase",
                "trigrams_filter"
              ],
              "type": "custom",
              "tokenizer": "standard"
            }
          },
          "tokenizer": {
            "fscrawler_path": {
              "type": "path_hierarchy"
            }
          }
        },
        "number_of_replicas": "1",
        "uuid": "7L3QE5_xRACECVbTFlFY-Q",
        "version": {
          "created": "6040399"
        }
      }
    }
  }
}

答案 1 :(得分:0)

我的地图

{
      "test": {
        "mappings": {
          "_doc": {
            "dynamic_templates": [
              {
                "raw_as_text": {
                  "path_match": "meta.raw.*",
                  "mapping": {
                    "fields": {
                      "keyword": {
                        "ignore_above": 256,
                        "type": "keyword"
                      }
                    },
                    "type": "text"
                  }
                }
              }
            ],
            "properties": {
              "attachment": {
                "type": "binary"
              },
              "attributes": {
                "properties": {
                  "group": {
                    "type": "keyword"
                  },
                  "owner": {
                    "type": "keyword"
                  }
                }
              },
              "content": {
                "type": "text"
              },
              "file": {
                "properties": {
                  "checksum": {
                    "type": "keyword"
                  },
                  "content_type": {
                    "type": "keyword"
                  },
                  "created": {
                    "type": "date",
                    "format": "dateOptionalTime"
                  },
                  "extension": {
                    "type": "keyword"
                  },
                  "filename": {
                    "type": "keyword",
                    "store": true
                  },
                  "filesize": {
                    "type": "long"
                  },
                  "indexed_chars": {
                    "type": "long"
                  },
                  "indexing_date": {
                    "type": "date",
                    "format": "dateOptionalTime"
                  },
                  "last_accessed": {
                    "type": "date",
                    "format": "dateOptionalTime"
                  },
                  "last_modified": {
                    "type": "date",
                    "format": "dateOptionalTime"
                  },
                  "url": {
                    "type": "keyword",
                    "index": false
                  }
                }
              },
              "meta": {
                "properties": {
                  "altitude": {
                    "type": "text"
                  },
                  "author": {
                    "type": "text"
                  },
                  "comments": {
                    "type": "text"
                  },
                  "contributor": {
                    "type": "text"
                  },
                  "coverage": {
                    "type": "text"
                  },
                  "created": {
                    "type": "date",
                    "format": "dateOptionalTime"
                  },
                  "creator_tool": {
                    "type": "keyword"
                  },
                  "date": {
                    "type": "date",
                    "format": "dateOptionalTime"
                  },
                  "description": {
                    "type": "text"
                  },
                  "format": {
                    "type": "text"
                  },
                  "identifier": {
                    "type": "text"
                  },
                  "keywords": {
                    "type": "text"
                  },
                  "language": {
                    "type": "keyword"
                  },
                  "latitude": {
                    "type": "text"
                  },
                  "longitude": {
                    "type": "text"
                  },
                  "metadata_date": {
                    "type": "date",
                    "format": "dateOptionalTime"
                  },
                  "modifier": {
                    "type": "text"
                  },
                  "print_date": {
                    "type": "date",
                    "format": "dateOptionalTime"
                  },
                  "publisher": {
                    "type": "text"
                  },
                  "rating": {
                    "type": "byte"
                  },
                  "relation": {
                    "type": "text"
                  },
                  "rights": {
                    "type": "text"
                  },
                  "source": {
                    "type": "text"
                  },
                  "title": {
                    "type": "text"
                  },
                  "type": {
                    "type": "text"
                  }
                }
              },
              "path": {
                "properties": {
                  "real": {
                    "type": "keyword",
                    "fields": {
                      "fulltext": {
                        "type": "text"
                      },
                      "tree": {
                        "type": "text",
                        "analyzer": "fscrawler_path",
                        "fielddata": true
                      }
                    }
                  },
                  "root": {
                    "type": "keyword"
                  },
                  "virtual": {
                    "type": "keyword",
                    "fields": {
                      "fulltext": {
                        "type": "text"
                      },
                      "tree": {
                        "type": "text",
                        "analyzer": "fscrawler_path",
                        "fielddata": true
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }