# Filter by specific value without mapping

**URL:** <https://discuss.elastic.co/t/filter-by-specific-value-without-mapping/20108>\
**Category:** Elasticsearch\
**Created:** [October 7, 2014, 9:57am UTC](https://discuss.elastic.co/t/filter-by-specific-value-without-mapping/20108 "2014-10-07T09:57:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vladimir\_Krylov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vladimir_krylov/32/1188_2.png) [@Vladimir\_Krylov](https://discuss.elastic.co/u/Vladimir_Krylov)\
**Post date:** [October 7, 2014, 9:57am UTC](https://discuss.elastic.co/t/filter-by-specific-value-without-mapping/20108/1 "2014-10-07T09:57:32Z")

</div>

What I'm trying to do is to get data by filtering term with exact  
matching. I have ES 1.3.2 and I cannot do mapping, as attributes are  
dynamic (different users has different attributes). My data:

{ id: 111,  
org\_id: 11,  
approval: "approved",  
...  
}

{ id: 112,  
org\_id: 11,  
approval: "not approved",  
...  
}

This request returns results:

curl -X GET 'host:9200/data/\_search?pretty' -d '{  
"filter":{  
"term":{  
"approval":"approved"  
}  
}  
}

But this not:

curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
"filter":{  
"term":{  
"approval":"not approved"  
}  
}  
}

It's a dup of  
ticket [https://github.com/elasticsearch/elasticsearch/issues/8006#issuecomment-58160111](https://github.com/elasticsearch/elasticsearch/issues/8006#issuecomment-58160111)  
As I was followed here.

David Pilato proposed that "index has indexed probably not and approved"  
and that there is no exact matching to "not approved". I tried to search  
for word "not" and it works

curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
"filter":{  
"term":{  
"approval":"not"  
}  
}  
}

So, how can I filter by exact word matching "not approved"?

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vladimir\_Krylov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vladimir_krylov/32/1188_2.png) [@Vladimir\_Krylov](https://discuss.elastic.co/u/Vladimir_Krylov)\
**Post date:** [October 7, 2014, 10:03am UTC](https://discuss.elastic.co/t/filter-by-specific-value-without-mapping/20108/2 "2014-10-07T10:03:56Z")

</div>

Just to be clear, actually I don't need any analyzer on filters

On Tuesday, October 7, 2014 12:57:32 PM UTC+3, Vladimir Krylov wrote:

> What I'm trying to do is to get data by filtering term with exact  
> matching. I have ES 1.3.2 and I cannot do mapping, as attributes are  
> dynamic (different users has different attributes). My data:
> 
> { id: 111,  
> org\_id: 11,  
> approval: "approved",  
> ...  
> }
> 
> { id: 112,  
> org\_id: 11,  
> approval: "not approved",  
> ...  
> }
> 
> This request returns results:
> 
> curl -X GET 'host:9200/data/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"approved"  
> }  
> }  
> }
> 
> But this not:
> 
> curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"not approved"  
> }  
> }  
> }
> 
> It's a dup of ticket  
> [Filter by specific value without mapping · Issue #8006 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/8006#issuecomment-58160111)  
> As I was followed here.
> 
> David Pilato proposed that "index has indexed probably not and approved"  
> and that there is no exact matching to "not approved". I tried to search  
> for word "not" and it works
> 
> curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"not"  
> }  
> }  
> }
> 
> So, how can I filter by exact word matching "not approved"?

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b4160387-cc59-48e4-9a96-ed29f32b4a6e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b4160387-cc59-48e4-9a96-ed29f32b4a6e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vladimir\_Krylov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vladimir_krylov/32/1188_2.png) [@Vladimir\_Krylov](https://discuss.elastic.co/u/Vladimir_Krylov)\
**Post date:** [October 7, 2014, 2:02pm UTC](https://discuss.elastic.co/t/filter-by-specific-value-without-mapping/20108/3 "2014-10-07T14:02:54Z")

</div>

I tried to set custom default analyzer  
curl -XPUT 'host:9200/reports' -d '  
{  
"settings":{  
"analysis": {  
"analyzer": {  
"default":{  
"type": "pattern",  
"pattern":"\_\_\_\_\_\_\_\_\_" // I know that cannot get  
this splitter  
}  
}  
}  
}  
}'  
curl '[http://host:9200/reports/\_analyze?pretty=1&field=filter\_\_approval](http://host:9200/reports/_analyze?pretty=1&field=filter__approval)' -d  
'not approved' # returns full string as one token  
curl '[http://host:9200/reports/\_analyze?pretty=1](http://host:9200/reports/_analyze?pretty=1)' -d 'foo,bar baz ASD: "  
fdfd "'# returns full string as one token

Seems to be working. Is there better solution?

On Tuesday, October 7, 2014 12:57:32 PM UTC+3, Vladimir Krylov wrote:

> What I'm trying to do is to get data by filtering term with exact  
> matching. I have ES 1.3.2 and I cannot do mapping, as attributes are  
> dynamic (different users has different attributes). My data:
> 
> { id: 111,  
> org\_id: 11,  
> approval: "approved",  
> ...  
> }
> 
> { id: 112,  
> org\_id: 11,  
> approval: "not approved",  
> ...  
> }
> 
> This request returns results:
> 
> curl -X GET 'host:9200/data/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"approved"  
> }  
> }  
> }
> 
> But this not:
> 
> curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"not approved"  
> }  
> }  
> }
> 
> It's a dup of ticket  
> [Filter by specific value without mapping · Issue #8006 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/8006#issuecomment-58160111)  
> As I was followed here.
> 
> David Pilato proposed that "index has indexed probably not and approved"  
> and that there is no exact matching to "not approved". I tried to search  
> for word "not" and it works
> 
> curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"not"  
> }  
> }  
> }
> 
> So, how can I filter by exact word matching "not approved"?

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ff22ac98-2028-4476-862e-7a2bb82c4f52%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ff22ac98-2028-4476-862e-7a2bb82c4f52%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 7, 2014, 2:16pm UTC](https://discuss.elastic.co/t/filter-by-specific-value-without-mapping/20108/4 "2014-10-07T14:16:54Z")

</div>

The field do not need a custom analyzer, they just need to be simply marked  
as non\_analyzed.

You can setup a dynamic template that states any new field should be non  
analyzed.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

You can still hardcode the mapping for specific fields.

Cheers,

Ivan  
On Oct 7, 2014 2:57 AM, "Vladimir Krylov" [s6numid@gmail.com](mailto:s6numid@gmail.com) wrote:

> What I'm trying to do is to get data by filtering term with exact  
> matching. I have ES 1.3.2 and I cannot do mapping, as attributes are  
> dynamic (different users has different attributes). My data:
> 
> { id: 111,  
> org\_id: 11,  
> approval: "approved",  
> ...  
> }
> 
> { id: 112,  
> org\_id: 11,  
> approval: "not approved",  
> ...  
> }
> 
> This request returns results:
> 
> curl -X GET 'host:9200/data/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"approved"  
> }  
> }  
> }
> 
> But this not:
> 
> curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"not approved"  
> }  
> }  
> }
> 
> It's a dup of ticket  
> [Filter by specific value without mapping · Issue #8006 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/8006#issuecomment-58160111)  
> As I was followed here.
> 
> David Pilato proposed that "index has indexed probably not and approved"  
> and that there is no exact matching to "not approved". I tried to search  
> for word "not" and it works
> 
> curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
> "filter":{  
> "term":{  
> "approval":"not"  
> }  
> }  
> }
> 
> So, how can I filter by exact word matching "not approved"?
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDpvwRMPmLTX2ung%2BS6o8nz0k2mMtgmvZwEQMSCygRAPw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDpvwRMPmLTX2ung%2BS6o8nz0k2mMtgmvZwEQMSCygRAPw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vladimir\_Krylov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vladimir_krylov/32/1188_2.png) [@Vladimir\_Krylov](https://discuss.elastic.co/u/Vladimir_Krylov)\
**Post date:** [October 17, 2014, 1:33pm UTC](https://discuss.elastic.co/t/filter-by-specific-value-without-mapping/20108/5 "2014-10-17T13:33:30Z")

</div>

Tried to remove papping and make not\_analizable  
curl -XPUT "http://:9200$HOST/reports" -d'  
{  
"mappings": {  
"_default_": {  
"dynamic\_templates": [  
{  
"store\_generic" : {  
"match" : "\*",  
"match\_mapping\_type" : "string",  
"mapping" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}

```
        }
     ]
  }

```

}  
}'

But Easy filtering returns empty results for "approved", "not approved" or  
"". Search example

curl -X GET '[http://localhost:9200/reports/\_search?pretty](http://localhost:9200/reports/_search?pretty)' -d '{  
"filter":{  
"term":{  
"general.approval": "approved"  
}  
}  
}  
'

Should I do other filtering syntax for this case?

On Tuesday, October 7, 2014 5:17:02 PM UTC+3, Ivan Brusic wrote:

> The field do not need a custom analyzer, they just need to be simply  
> marked as non\_analyzed.
> 
> You can setup a dynamic template that states any new field should be non  
> analyzed.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_dynamic_templates)
> 
> You can still hardcode the mapping for specific fields.
> 
> Cheers,
> 
> Ivan  
> On Oct 7, 2014 2:57 AM, "Vladimir Krylov" \<[s6n...@gmail.com](mailto:s6n...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > What I'm trying to do is to get data by filtering term with exact  
> > matching. I have ES 1.3.2 and I cannot do mapping, as attributes are  
> > dynamic (different users has different attributes). My data:
> > 
> > { id: 111,  
> > org\_id: 11,  
> > approval: "approved",  
> > ...  
> > }
> > 
> > { id: 112,  
> > org\_id: 11,  
> > approval: "not approved",  
> > ...  
> > }
> > 
> > This request returns results:
> > 
> > curl -X GET 'host:9200/data/\_search?pretty' -d '{  
> > "filter":{  
> > "term":{  
> > "approval":"approved"  
> > }  
> > }  
> > }
> > 
> > But this not:
> > 
> > curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
> > "filter":{  
> > "term":{  
> > "approval":"not approved"  
> > }  
> > }  
> > }
> > 
> > It's a dup of ticket  
> > [Filter by specific value without mapping · Issue #8006 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/8006#issuecomment-58160111)  
> > As I was followed here.
> > 
> > David Pilato proposed that "index has indexed probably not and approved"  
> > and that there is no exact matching to "not approved". I tried to search  
> > for word "not" and it works
> > 
> > curl -X GET 'host:9200/reports/\_search?pretty' -d '{  
> > "filter":{  
> > "term":{  
> > "approval":"not"  
> > }  
> > }  
> > }
> > 
> > So, how can I filter by exact word matching "not approved"?
> > 
> > --  
> > 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:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6ea46153-68a7-481f-9064-9e094094bf29%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4cc3fe20-296c-4a63-af9c-ec1516e3f54e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4cc3fe20-296c-4a63-af9c-ec1516e3f54e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:55am UTC](https://discuss.elastic.co/t/filter-by-specific-value-without-mapping/20108/6 "2017-07-06T00:55:30Z")

</div>


