【问题标题】:How to put additional settings when index in aws elasticsearch using node.js使用node.js在aws elasticsearch中索引时如何放置其他设置
【发布时间】:2020-06-15 18:25:40
【问题描述】:

我将在 client.index 函数中添加额外的设置细节。 这是我尝试过的。

return client
    .index({
      index: indexName,
      type: "file",
      id: bucketName + "/" + fileKey,
      body: {
        title: fileName,
        content: contentString,
        fileKey: fileKey,
        bucketName: bucketName,
        updated: Date.now(),
        type: fileType,
      },
    })

如何将分析详细信息放入其中? 这就是我要说的。

{
   settings: {
      analysis: {
         analyze: {
             tokenizer: "icu-tokenizer"
         }
      }
   }
}

最后应该是这样的:

{
    "ghej": {
        "aliases": {},
        "mappings": {},
        "settings": {
            "index": {
                "number_of_shards": "5",
                "provided_name": "ghej",
                "creation_date": "1592239308694",
                "analysis": {
                    "analyzer": {
                        "content": {
                            "type": "custom",
                            "tokenizer": "icu_tokenizer"
                        }
                    }
                },
                "number_of_replicas": "1",
                "uuid": "1yX6z-eARdyNakJwM6Z3ow",
                "version": {
                    "created": "7010199"
                }
            }
        }
    }
}

任何帮助将不胜感激。

【问题讨论】:

    标签: javascript elasticsearch aws-sdk aws-elasticsearch


    【解决方案1】:

    "settings" 属性必须位于"body" 属性内。

    您需要在正文中定义分析器/标记器参数以及应执行分析的文本

    可以参考这位官方documentation

    returnclient.index({
      index: indexName,
      type: "file",
      id: bucketName+"/"+fileKey,
      body: {
        "settings": {
          "analysis": {
            "analyzer": {
              "my_icu_analyzer": {
                "tokenizer": "icu_tokenizer"
              }
            }
          }
        }
      }
    
    })
    

    您可以参考这些博客并回答以了解更多信息

    Elasticsearch Analyzer

    Custom Made Analyzer

    Integrate Elasticsearch with Node.js

    【讨论】:

    • @U_M 你有没有机会仔细阅读我的回答,期待得到你的反馈,如果有帮助,请不要忘记点赞并接受:)
    猜你喜欢
    • 2017-07-04
    • 2019-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-11
    • 1970-01-01
    • 2020-03-24
    相关资源
    最近更新 更多