简体   繁体   中英

ElasticSearch: Altering indexed version of text

Before the text in a field is indexed, I want to run code on it to transform it, basically what's going on here https://www.elastic.co/guide/en/elasticsearch/reference/master/gsub-processor.html (but that feature isn't out yet).

For example, I want to be able to transform all . in a field into - for the indexed version.

Any advice? Doing this in elasticsearch-rails.

Use a char_filter where you replace all . into - but this will change the characters of the indexed terms, not the _source itself . Something like this:

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

or use Logstash with mutate and gsub filter to pre-process the data before being sent to Elasticsearch. Or you do it in your own indexer (whatever that is).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM