Elastic search: map property types using wildcard for property name
<p>I want to apply a mapping to all properties. Can I do so without naming the property.</p>

<p>e.g.</p>

<pre><code>'body' =&gt; [
    'doc_type' =&gt;
        'properties' =&gt;
            'networks' =&gt;
                'properties' =&gt; [
                    '*' =&gt; ['type' =&gt; 'integer']
                ]
            ]
        ]
    ]
]
</code></pre>

<p>Instead of:</p>

<pre><code>'properties' =&gt; [
    'vip10415' =&gt; ['type' =&gt; 'integer'],
    'vip86485' =&gt; ['type' =&gt; 'integer'],
    'vip23465' =&gt; ['type' =&gt; 'integer'],
    'vip97949' =&gt; ['type' =&gt; 'integer']
    ....
 ]
</code></pre>

<p>The reason I want to do this is because it isn't known until runtime what properties will be used.</p>

<p>I know queries can have wildcards, but haven't seen if mappings can. I looked at dynamic mappings but it didn't work like this.</p>

<p>Update:</p>

<p>I have tried inserting ints and letting elastic infer their type but it parses them as type 'long'. I am inserting using php and ensured they were ints with the intval() function.</p>

<p>Update:</p>

<p>'properties' are actually a sub field of a nested property 'Networks'. The name of the property to be stored as an int will not be known until runtime.</p>

<p>Update:</p>

<p>I've tried applying dynamic mapping templates recommend by @bittusarkar in the doc_type, but it throws an unable to parse mapping exception.</p>

<pre><code>"dynamic_templates" =&gt; [
    "integers" =&gt; [
        "match_mapping_type" =&gt; "long",
        "mapping" =&gt; [
            "type" =&gt; "integer"
        ]
    ]
]
</code></pre>