Dot in field names in ES7.11

Hello,

I currently have the same problem as the one described here : How to handle dot in field names in ES 7.0

Unfortunately, I can't modify the document field names as suggested in the last update.

Is there any other solution?
I also read that a setting existed in ES2.4 (mapper.allow_dots_in_name described here : Dots in field names | Elasticsearch Guide [2.4] | Elastic). What about this setting? Can it still be used?

Thanks in advance for you help!

Welcome!

Fields with dot in names are automatically converted to objects.

DELETE test
PUT test
{
  "mappings" : {
    "properties" : {
      "foo.bar" : {
        "type" : "text"
      }
    }
  }
}
POST test/_doc
{
  "foo.bar": "baz"
}
GET test/_mapping

Gives:

{
  "test" : {
    "mappings" : {
      "properties" : {
        "foo" : {
          "properties" : {
            "bar" : {
              "type" : "text"
            }
          }
        }
      }
    }
  }
}

So you can hopefully change documents on the fly using an ingest pipeline like with a rename processor.

Something like:

PUT _ingest/pipeline/dotreplace
{
  "processors": [
    {
      "dot_expander": {
        "field": "foo.bar"
      }
    },
    {
      "rename": {
        "field": "foo.bar",
        "target_field": "foo_bar"
      }
    },
    {
      "remove": {
        "field": "foo"
      }
    }
  ]
}
DELETE test
PUT test
{
  "settings": {
    "index.default_pipeline": "dotreplace"
  },
  "mappings" : {
    "properties" : {
      "foo_bar" : {
        "type" : "text"
      }
    }
  }
}
PUT test/_doc/1
{
  "foo.bar": "baz"
}
GET test/_doc/1

which gives:

{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "foo_bar" : "baz"
  }
}
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.