首页 文章

Couchbase文档映射到elasticsearch

提问于
浏览
0

我正在尝试将数据从沙发基础桶复制到elasticsearch索引“test” . 我已经为我的“测试索引”进行了以下设置 .

"settings": {
"analysis": {
  "analyzer": {
    "my_analyzer":{
    "type":"custom",
    "tokenizer" : "standard",
    "filter" : ["standard", "lowercase","asciifolding","my_stemmer","autocomplete","my_stop","my_synonym_filter"]
    }
  },
  "filter": {
    "my_stemmer":{
      "type":"stemmer",
      "name":"english"
    },
    "autocomplete":{
      "type":"edge_ngram",
      "min_gram":1,
      "max_gram":20
    },
    "my_stop":{
      "type":"stop",
       "stopwords":"_english_"
    },
    "my_synonym_filter":{
      "type":"synonym",
      "synonyms": [
        "united states,u s a,united states of                   america=>usa"
      ]
    }
  }
}

我有类型 - “配置文件”的映射如下 .

"profile":{
    "properties": {
    "name":{
      "type": "string",
      "index_analyzer": "my_analyzer",
      "search_analyzer": "english"
    },
    "title":{
      "type": "string",
      "index_analyzer": "my_analyzer",
      "search_analyzer": "english"
    },
    "description":{
      "type": "string",
      "search_analyzer": "english",
      "index_analyzer": "my_analyzer"
    },

我的沙发基础文件如下 .

{
  "name": "xxxx",
  "title": "junior android developer",
  "description": "I am developing new android applications",}

我的问题是,

  • 当我将此文档复制到elasticsearch时,如何使用此设置和映射为此沙发基础文档?

  • couch base transport plugin默认将此文档映射到“couchbaseDocument”类型,而elasticsearch自动映射此文档 . 如何更改此行为?

请帮我 . 非常感谢你提前 .

1 回答

  • 1

    要将所有“profile:xxx”文档映射到ES中的“profile”类型,只需在插件配置中添加类型设置即可 . 在您的情况下,将以下内容添加到每个ES节点上的elasticsearch.yml配置文件中:

    couchbase.typeSelector: org.elasticsearch.transport.couchbase.capi.DelimiterTypeSelector
    

    DelimiterTypeSelector 用分隔符(默认为':')拆分文档ID,并使用第一个标记作为文档类型,这正是您想要的 . 将文档映射到正确的类型后,ES将使用您自动配置的映射 .

    看看here,您可以使用其他一些高级设置 . 特别是,您可能希望使用 couchbase.ignoreFailures 设置 .

相关问题