使用Elastic4s的动态弹性搜索映射 [英] Dynamic ElasticSearch mapping using Elastic4s

查看:146
本文介绍了使用Elastic4s的动态弹性搜索映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我想在elasticSearch上索引的文档,该文档包含一些我不能提前知道的动态键,如下面的例子中的西班牙语或法语

I have a document that I want to index on elasticSearch, this document contains some dynamic keys that I can not know in advance, like "spanish" or "french" in the following example

"contents": {
    "title": {
        "spanish": "Hola amigos",
        "french" : "Bonjour les amis"
    }
}

我正在使用elastic4s DSL为了进行映射(通过createIndex DSL ),但是我不能找到如何使用此库创建基于匹配选项的动态映射(如建议这里),以便为路径contents.title中存储的每种语言指定不同的分析器。

I'm using the elastic4s DSL in order to make my mapping (Via the createIndex DSL), but I can not find how to create, with this library, a dynamic mapping based on the "match" option ( like suggested here), in order to specify a different analyzer for each language stored under the path contents.title.

任何曲目请 ? : - )

Any track please ? :-)

推荐答案

目前您无法在elastic4s Scala API中执行所需的操作。但是您可以在Java API中创建一个动态模板,并在其余的调用中使用Scala API。

You can't do what you want in the elastic4s Scala API at the moment. But you can create a dynamic template in the Java API and use the Scala API for the rest of your calls.

可以将动态模板设置为使用正则表达式并应用映射。但是,既然你真的会真的知道你的国家(只有〜200)为什么不花时间做映射?

The dynamic template can be set to use a regex and apply a mapping. But since you will really know your countries in advance (there's only ~200) why not just spend the time and make a mapping?

这篇关于使用Elastic4s的动态弹性搜索映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆