ElasticSearch:更改文本的索引版本

时间:2016-10-22 22:00:45

标签: ruby-on-rails elasticsearch

在对字段中的文本编制索引之前,我想在其上运行代码以对其进行转换,基本上是在https://www.elastic.co/guide/en/elasticsearch/reference/master/gsub-processor.html发生了什么(但该功能还没有出来)。

例如,我希望能够将字段中的所有.转换为-索引版本。

有什么建议吗?在elasticsearch-rails中执行此操作。

1 个答案:

答案 0 :(得分:1)

使用char_filter将所有.替换为-,但这会更改索引字词的字符,而不是_source本身。像这样:

        "char_filter" : {
            "my_mapping" : {
                "type" : "mapping",
                "mappings" : [
                  ". => -"
                ]
            }
        }

或使用带有mutate and gsub filter的Logstash在发送到Elasticsearch之前预处理数据。或者你在自己的索引器中做到这一点(无论是什么)。