Nested datatype and dynamic mapping

Hi,

I have a nested object which is mapped as follow:

         "product": {
            "type": "nested",
            "properties": {
              "id": {
                "type": "long"
              }
              "level": {
                "type": "long"
              }
              "name": {
                "type": "text"
              }
            }

I also have a dynamic template as follow to add "raw" as a keyword type to text data type:

"dynamic_templates": [
      {
        "strings_as_keywords": {
          "match_mapping_type": "string",
          "mapping": {
            "fields": {
              "raw": {
                "ignore_above": 1024,
                "type": "keyword"
              }
            },
            "norms": false,
            "type": "text"
          }
        }
      }
 ...

Now my problem is, everything in this nested object works as expected except the nested aggregation over only text field (not the long data type). And that is because Fielddata is disabled on text fields and when I look at the _mapping of my created index I don't see the "raw" field as well.

So my question is, why the dynamic template works for all the others but not for this nested object? And what would you suggest to have both text/keyword in nested data type.

Thanks,
Maziyar

Ok I had to fix the mapping as the following and re-index each index by using Reindex API, dynamic mapping didn't work on the nested objects:

      "product": {
        "type": "nested",
        "properties": {
          "name": {
            "type": "text",
           "fields": {
              "raw": {
                "type": "keyword"
              }
            }
          }

Best,
Maziyar

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