# Facet filtering on strings with special characters

**URL:** https://discuss.elastic.co/t/facet-filtering-on-strings-with-special-characters/14194
**Category:** Elasticsearch
**Created:** [October 31, 2013, 4:50pm UTC](https://discuss.elastic.co/t/facet-filtering-on-strings-with-special-characters/14194 "2013-10-31T16:50:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Alex\_Malgaroli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_malgaroli/32/2005_2.png) [@Alex\_Malgaroli](https://discuss.elastic.co/u/Alex_Malgaroli)
#### Post date: [October 31, 2013, 4:50pm UTC](https://discuss.elastic.co/t/facet-filtering-on-strings-with-special-characters/14194/1 "2013-10-31T16:50:02Z")

</div>

Hi all,

I am working with a mapping and data structure that's mostly similar to the  
one described here: [https://gist.github.com/zwrss/5188008](https://gist.github.com/zwrss/5188008)  
(my use case is also similar to what lead to that gist, check the entire  
topic here  
[https://groups.google.com/d/topic/elasticsearch/fK08asuV7y8/discussion](https://groups.google.com/d/topic/elasticsearch/fK08asuV7y8/discussion),  
basically I'm following Clinton Gormley's suggestion)

Point is that when I try to run a facet like this one:  
"type" : {  
"terms" : { "field" : "type" },  
"facet\_filter" : {  
"and" : [  
{ "term" : { "characteristics" : "warranty\_3 years" } },  
]  
}  
},

I always get 0 result. It seems like the "\_" gets tokenized and removed  
when searching as if the field were analyzed. The mapping for the  
characteristics field it's tyoe: string, index: "not\_analyzed".

Any idea what could be possibly wrong?

Thanks in advance.

AM

--  
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: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [November 1, 2013, 12:07am UTC](https://discuss.elastic.co/t/facet-filtering-on-strings-with-special-characters/14194/2 "2013-11-01T00:07:53Z")

</div>

The term in a term filter is never analyzed, regardless of the analyzer set  
on the field.

When you say that you get 0 results, does that mean your query gets zero  
results or there are no entries in the facet? What happens when you do not  
apply the facet filter?

On Thu, Oct 31, 2013 at 9:50 AM, Alex Malgaroli [alex.malgaroli@gmail.com](mailto:alex.malgaroli@gmail.com)wrote:

> Hi all,
> 
> I am working with a mapping and data structure that's mostly similar to  
> the one described here: [Mappings for elasticsearch not nested stuff · GitHub](https://gist.github.com/zwrss/5188008)  
> (my use case is also similar to what lead to that gist, check the entire  
> topic here  
> [https://groups.google.com/d/topic/elasticsearch/fK08asuV7y8/discussion](https://groups.google.com/d/topic/elasticsearch/fK08asuV7y8/discussion),  
> basically I'm following Clinton Gormley's suggestion)
> 
> Point is that when I try to run a facet like this one:  
> "type" : {  
> "terms" : { "field" : "type" },  
> "facet\_filter" : {  
> "and" : [  
> { "term" : { "characteristics" : "warranty\_3 years" } },  
> ]  
> }  
> },
> 
> I always get 0 result. It seems like the "\_" gets tokenized and removed  
> when searching as if the field were analyzed. The mapping for the  
> characteristics field it's tyoe: string, index: "not\_analyzed".
> 
> Any idea what could be possibly wrong?
> 
> Thanks in advance.
> 
> AM
> 
> --  
> 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).

--  
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: ![Alex\_Malgaroli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_malgaroli/32/2005_2.png) [@Alex\_Malgaroli](https://discuss.elastic.co/u/Alex_Malgaroli)
#### Post date: [November 1, 2013, 10:03am UTC](https://discuss.elastic.co/t/facet-filtering-on-strings-with-special-characters/14194/3 "2013-11-01T10:03:30Z")

</div>

HI Ivan.  
I made again some experiments and actually I got the expected results.  
There may have been a typo in the query or filter on my part which I didn't  
see.

Sorry for the inconvenience

AM

On Fri, Nov 1, 2013 at 1:07 AM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> The term in a term filter is never analyzed, regardless of the analyzer  
> set on the field.
> 
> When you say that you get 0 results, does that mean your query gets zero  
> results or there are no entries in the facet? What happens when you do not  
> apply the facet filter?
> 
> On Thu, Oct 31, 2013 at 9:50 AM, Alex Malgaroli [alex.malgaroli@gmail.com](mailto:alex.malgaroli@gmail.com)wrote:
> 
> > Hi all,
> > 
> > I am working with a mapping and data structure that's mostly similar to  
> > the one described here: [Mappings for elasticsearch not nested stuff · GitHub](https://gist.github.com/zwrss/5188008)  
> > (my use case is also similar to what lead to that gist, check the entire  
> > topic here  
> > [https://groups.google.com/d/topic/elasticsearch/fK08asuV7y8/discussion](https://groups.google.com/d/topic/elasticsearch/fK08asuV7y8/discussion),  
> > basically I'm following Clinton Gormley's suggestion)
> > 
> > Point is that when I try to run a facet like this one:  
> > "type" : {  
> > "terms" : { "field" : "type" },  
> > "facet\_filter" : {  
> > "and" : [  
> > { "term" : { "characteristics" : "warranty\_3 years" } },  
> > ]  
> > }  
> > },
> > 
> > I always get 0 result. It seems like the "\_" gets tokenized and removed  
> > when searching as if the field were analyzed. The mapping for the  
> > characteristics field it's tyoe: string, index: "not\_analyzed".
> > 
> > Any idea what could be possibly wrong?
> > 
> > Thanks in advance.
> > 
> > AM
> > 
> > --  
> > 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).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/P2UZfnWiV14/unsubscribe](https://groups.google.com/d/topic/elasticsearch/P2UZfnWiV14/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).

## --

Taxation is just a sophisticated way of demanding money with menaces  
[Terry Pratchett, Night Watch]

--  
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:09am UTC](https://discuss.elastic.co/t/facet-filtering-on-strings-with-special-characters/14194/4 "2017-07-06T02:09:22Z")

</div>


