Whitelisted mapping for properties of unknown type


(brainsiq) #1

I have a scenario where I want to index only "whitelisted" fields but I am having a problem because I do not know at index time what the types of these fields should be. My first step was to create a dynamic mapping to disable all fields by default:

{
    "my-type": {
        "dynamic_templates": [
            {
                "notsearchable": {
                    "match": "*",
                    "mapping": {
                        "index": "no"
                    }
                }
            }
        ]
    }
}

I hoped I could then define the properties to allow but have not been able to find how to do it. I have tried:

  • Defining the whitelisted properties without a type, but type is required
  • Defining the whitelisted properties with '{dynamic_type}', but this not allowed in the properties section, only in a template (or maybe only in 2.0)
  • Defining another template to try and match any of multiple whitelisted field names but it looks like match only supports wildcards and not regular expressions (in 1.7, not 2.0 which looks like it would support that).

Is there another way of achieving this? I do not know what fields are going to be submitted so cannot disable specific fields either. Would be really grateful for some help!


(system) #2