# Providing multiple path\_unmatch while defining dynamic templates

**URL:** https://discuss.elastic.co/t/providing-multiple-path-unmatch-while-defining-dynamic-templates/11467
**Category:** Elasticsearch
**Created:** [April 5, 2013, 8:09pm UTC](https://discuss.elastic.co/t/providing-multiple-path-unmatch-while-defining-dynamic-templates/11467 "2013-04-05T20:09:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![shadyabhi](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@shadyabhi](https://discuss.elastic.co/u/shadyabhi)
#### Post date: [April 5, 2013, 8:09pm UTC](https://discuss.elastic.co/t/providing-multiple-path-unmatch-while-defining-dynamic-templates/11467/1 "2013-04-05T20:09:29Z")

</div>

Hi,

We can define a dynamic template like:

```
            {
                "fields_template" : {
                    "mapping": { "type": "string", "index":

```

"not\_analyzed" },  
"path\_match": "@fields.\*",  
"path\_unmatch": "@fields.size"  
}  
}

Is there a way to define multiple path\_unmatch? I've a requirement where I  
need to exclude more than one fields from that regex but I also can't give  
away with regex in path\_match.

What are my options?

--  
Regards,  
Abhijeet Rastogi (shadyabhi)

> **[Abhijeet's Blog](https://blog.abhijeetr.com/)**
>
> I write about problems that I solve

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [April 8, 2013, 5:44pm UTC](https://discuss.elastic.co/t/providing-multiple-path-unmatch-while-defining-dynamic-templates/11467/2 "2013-04-08T17:44:01Z")

</div>

I am not sure I fully understand the reasons why you cannot use regex match  
for both path\_match and path\_unmatch. Could you elaborate on this?

On Friday, April 5, 2013 4:09:29 PM UTC-4, Abhijeet Rastogi wrote:

> Hi,
> 
> We can define a dynamic template like:
> 
> ```
> {   
> "fields_template" : { 
> "mapping": { "type": "string", "index": 
> 
> ```
> 
> "not\_analyzed" },  
> "path\_match": "@fields.\*",  
> "path\_unmatch": "@fields.size"  
> }  
> }
> 
> Is there a way to define multiple path\_unmatch? I've a requirement where I  
> need to exclude more than one fields from that regex but I also can't give  
> away with regex in path\_match.
> 
> What are my options?
> 
> --  
> Regards,  
> Abhijeet Rastogi (shadyabhi)  
> [http://blog.abhijeetr.com](http://blog.abhijeetr.com)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![shadyabhi](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@shadyabhi](https://discuss.elastic.co/u/shadyabhi)
#### Post date: [April 18, 2013, 9:59am UTC](https://discuss.elastic.co/t/providing-multiple-path-unmatch-while-defining-dynamic-templates/11467/3 "2013-04-18T09:59:17Z")

</div>

Hi Igor,

Sorry for late reply. The reply got missed in filters and I wasn't  
notified. My current template looks like: [http://pb.abhijeetr.com/RiUH](http://pb.abhijeetr.com/RiUH) and  
indices are created with the name "logstash-date-here".

These are basically logs and text from logs is parsed and corresponding  
fields are created. My aim is to not analyse all "@fields.\*" but specify  
analyzers for only the fields I want, in the above template (  
[http://pb.abhijeetr.com/RiUH](http://pb.abhijeetr.com/RiUH)), "@fields.syslog\_message" (want it whitespace  
analyzed) & "@fields.size". (want it to be a long so that I can use  
term\_stats facets).

Another issue that's popping up while using this template is,  
[http://stackoverflow.com/questions/16078561/getting-infinity-and-infinity-in-terms-stats-query](http://stackoverflow.com/questions/16078561/getting-infinity-and-infinity-in-terms-stats-query),  
I feel like the way I'm specifying @fields.size as long is messy.

On Mon, Apr 8, 2013 at 11:14 PM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> I am not sure I fully understand the reasons why you cannot use regex  
> match for both path\_match and path\_unmatch. Could you elaborate on this?
> 
> On Friday, April 5, 2013 4:09:29 PM UTC-4, Abhijeet Rastogi wrote:
> 
> > Hi,
> > 
> > We can define a dynamic template like:
> > 
> > ```
> > {
> > "fields_template" : {
> > "mapping": { "type": "string", "index":
> > 
> > ```
> > 
> > "not\_analyzed" },  
> > "path\_match": "@fields.\*",  
> > "path\_unmatch": "@fields.size"  
> > }  
> > }
> > 
> > Is there a way to define multiple path\_unmatch? I've a requirement where  
> > I need to exclude more than one fields from that regex but I also can't  
> > give away with regex in path\_match.
> > 
> > What are my options?
> > 
> > --  
> > Regards,  
> > Abhijeet Rastogi (shadyabhi)  
> > [http://blog.abhijeetr.com](http://blog.abhijeetr.com)
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Regards,  
Abhijeet Rastogi (shadyabhi)  
[http://blog.abhijeetr.com](http://blog.abhijeetr.com)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [April 18, 2013, 9:34pm UTC](https://discuss.elastic.co/t/providing-multiple-path-unmatch-while-defining-dynamic-templates/11467/4 "2013-04-18T21:34:11Z")

</div>

Dynamic templates are applied only to fields that are created dynamically.  
In other words, if a field is already defined in the mappings (in the  
properties sections), it is not affected by dynamic templates in any way.  
So, you don't need to list such fields in "path\_unmatch".

On Thursday, April 18, 2013 5:59:17 AM UTC-4, Abhijeet Rastogi wrote:

> Hi Igor,
> 
> Sorry for late reply. The reply got missed in filters and I wasn't  
> notified. My current template looks like: [http://pb.abhijeetr.com/RiUHand](http://pb.abhijeetr.com/RiUHand) indices are created with the name "logstash-date-here".
> 
> These are basically logs and text from logs is parsed and corresponding  
> fields are created. My aim is to not analyse all "@fields.\*" but specify  
> analyzers for only the fields I want, in the above template (  
> [http://pb.abhijeetr.com/RiUH](http://pb.abhijeetr.com/RiUH)), "@fields.syslog\_message" (want it  
> whitespace analyzed) & "@fields.size". (want it to be a long so that I can  
> use term\_stats facets).
> 
> Another issue that's popping up while using this template is,  
> [http://stackoverflow.com/questions/16078561/getting-infinity-and-infinity-in-terms-stats-query](http://stackoverflow.com/questions/16078561/getting-infinity-and-infinity-in-terms-stats-query), I feel like the way I'm specifying @fields.size as long is messy.
> 
> On Mon, Apr 8, 2013 at 11:14 PM, Igor Motov \<[imo...@gmail.com](mailto:imo...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > I am not sure I fully understand the reasons why you cannot use regex  
> > match for both path\_match and path\_unmatch. Could you elaborate on this?
> > 
> > On Friday, April 5, 2013 4:09:29 PM UTC-4, Abhijeet Rastogi wrote:
> > 
> > > Hi,
> > > 
> > > We can define a dynamic template like:
> > > 
> > > ```
> > > {   
> > > "fields_template" : { 
> > > "mapping": { "type": "string", "index": 
> > > 
> > > ```
> > > 
> > > "not\_analyzed" },  
> > > "path\_match": "@fields.\*",  
> > > "path\_unmatch": "@fields.size"  
> > > }  
> > > }
> > > 
> > > Is there a way to define multiple path\_unmatch? I've a requirement where  
> > > I need to exclude more than one fields from that regex but I also can't  
> > > give away with regex in path\_match.
> > > 
> > > What are my options?
> > > 
> > > --  
> > > Regards,  
> > > Abhijeet Rastogi (shadyabhi)  
> > > [http://blog.abhijeetr.com](http://blog.abhijeetr.com)
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Regards,  
> Abhijeet Rastogi (shadyabhi)  
> [http://blog.abhijeetr.com](http://blog.abhijeetr.com)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![shadyabhi](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@shadyabhi](https://discuss.elastic.co/u/shadyabhi)
#### Post date: [April 19, 2013, 10:07am UTC](https://discuss.elastic.co/t/providing-multiple-path-unmatch-while-defining-dynamic-templates/11467/5 "2013-04-19T10:07:29Z")

</div>

Hi Igor,

I observed differently than what you said. Please have a look at this post  
[http://elasticsearch-users.115913.n3.nabble.com/Getting-Infinity-and-Infinity-in-terms-stats-query-What-does-it-mean-tp4033518p4033639.html](http://elasticsearch-users.115913.n3.nabble.com/Getting-Infinity-and-Infinity-in-terms-stats-query-What-does-it-mean-tp4033518p4033639.html)

It's another post you replied in.

On Fri, Apr 19, 2013 at 3:04 AM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> Dynamic templates are applied only to fields that are created dynamically.  
> In other words, if a field is already defined in the mappings (in the  
> properties sections), it is not affected by dynamic templates in any way.  
> So, you don't need to list such fields in "path\_unmatch".
> 
> On Thursday, April 18, 2013 5:59:17 AM UTC-4, Abhijeet Rastogi wrote:
> 
> > Hi Igor,
> > 
> > Sorry for late reply. The reply got missed in filters and I wasn't  
> > notified. My current template looks like: [http://pb.abhijeetr.com/RiUHand](http://pb.abhijeetr.com/RiUHand) indices are created with the name "logstash-date-here".
> > 
> > These are basically logs and text from logs is parsed and corresponding  
> > fields are created. My aim is to not analyse all "@fields.\*" but specify  
> > analyzers for only the fields I want, in the above template (  
> > [http://pb.abhijeetr.com/RiUH](http://pb.abhijeetr.com/RiUH)), "@fields.syslog\_message" (want it  
> > whitespace analyzed) & "@fields.size". (want it to be a long so that I can  
> > use term\_stats facets).
> > 
> > Another issue that's popping up while using this template is,  
> > [http://stackoverflow.com/\*\*questions/16078561/getting-](http://stackoverflow.com/**questions/16078561/getting-)\*\*  
> > infinity-and-infinity-in-\*\*terms-stats-query[http://stackoverflow.com/questions/16078561/getting-infinity-and-infinity-in-terms-stats-query](http://stackoverflow.com/questions/16078561/getting-infinity-and-infinity-in-terms-stats-query), I feel like the way I'm specifying @fields.size as long is messy.
> > 
> > On Mon, Apr 8, 2013 at 11:14 PM, Igor Motov [imo...@gmail.com](mailto:imo...@gmail.com) wrote:
> > 
> > > I am not sure I fully understand the reasons why you cannot use regex  
> > > match for both path\_match and path\_unmatch. Could you elaborate on this?
> > > 
> > > On Friday, April 5, 2013 4:09:29 PM UTC-4, Abhijeet Rastogi wrote:
> > > 
> > > > Hi,
> > > > 
> > > > We can define a dynamic template like:
> > > > 
> > > > ```
> > > > {
> > > > "fields_template" : {
> > > > "mapping": { "type": "string", "index":
> > > > 
> > > > ```
> > > > 
> > > > "not\_analyzed" },  
> > > > "path\_match": "@fields.\*",  
> > > > "path\_unmatch": "@fields.size"  
> > > > }  
> > > > }
> > > > 
> > > > Is there a way to define multiple path\_unmatch? I've a requirement  
> > > > where I need to exclude more than one fields from that regex but I also  
> > > > can't give away with regex in path\_match.
> > > > 
> > > > What are my options?
> > > > 
> > > > --  
> > > > Regards,  
> > > > Abhijeet Rastogi (shadyabhi)  
> > > > [http://blog.abhijeetr.com](http://blog.abhijeetr.com)
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > Regards,  
> > Abhijeet Rastogi (shadyabhi)  
> > [http://blog.abhijeetr.com](http://blog.abhijeetr.com)
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Regards,  
Abhijeet Rastogi (shadyabhi)  
[http://blog.abhijeetr.com](http://blog.abhijeetr.com)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 2:40am UTC](https://discuss.elastic.co/t/providing-multiple-path-unmatch-while-defining-dynamic-templates/11467/6 "2017-07-06T02:40:27Z")

</div>


