Hi to all,
I've started using ES 6 for a project where I'm indexing the objects of an inventory.
Those object have some fixed fields and some additional fields that I have indexed in a dynamic object.
I have also used the dynamic template to map all the field string in that object as a text + keyword (using multi-field).
{
"properties": {
    "object_type_id": {
        "type": "integer"
    },
    "inventory_id": {
        "type": "integer"
    },
    "label": {
        "type": "text",
        "fields": {
            "raw": {
                "type": "keyword",
                "normalizer": "keyword_lowercase"
            }
        }
    },
 	...
    "place.name": {
        "type": "text",
        "fields": {
            "raw": {
                "type": "keyword",
                "normalizer": "keyword_lowercase"
            }
        }
    },
    "extra_data": {
        "type": "object",
        "dynamic": true
    }
},
"dynamic_templates": [{
    "strings": {
        "match_mapping_type": "string",
        "mapping": {
            "type": "text",
            "fields": {
                "raw": {
                    "type": "keyword",
                    "normalizer": "keyword_lowercase"
                }
            }
        }
    }
}]
}
That all work for filtering, but I have some trouble with the sorting:
I don't know which of the field is transformed as text + keyword, so I don't know on which to use the internal .raw value.
There's any way I can instruct elasticsearch to use the internal field for sorting? Or any way to conditionally switch the field?
Any other solution?
Thanks to all
Cheers Mix