# Underscores in search term

**URL:** <https://discuss.elastic.co/t/underscores-in-search-term/3793>\
**Category:** Elasticsearch\
**Created:** [January 17, 2011, 8:13pm UTC](https://discuss.elastic.co/t/underscores-in-search-term/3793 "2011-01-17T20:13:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katrina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/katrina/32/3288_2.png) [@Katrina](https://discuss.elastic.co/u/Katrina)\
**Post date:** [January 17, 2011, 8:13pm UTC](https://discuss.elastic.co/t/underscores-in-search-term/3793/1 "2011-01-17T20:13:44Z")

</div>

This is the behavior that I'm observing:

With the following two records:

curl -XPUT '[http://localhost:9200/craft/project/1](http://localhost:9200/craft/project/1)' -d '  
{  
"kiddo" : "wendy",  
"category" : "art\_doll",  
"material" : "felt",  
"title" : "A pretty doll"  
}  
'  
curl -XPUT '[http://localhost:9200/craft/project/2](http://localhost:9200/craft/project/2)' -d '  
{  
"kiddo" : "wendy",  
"category" : "art\_box",  
"material" : "cardboard",  
"title" : "A functional box"  
}  
'

If I do a term query on category for "art\_doll" I get zero results  
back. If I query for "art" I get two results back.

I thought maybe term would return documents where the category was a  
partial match for the word (art\_box, art\_doll), but then I would have  
expected the materials query to return 1 result for "card", matching  
on the word "cardboard", but I get 0 results back for "card".

These are the actual queries that I am running against the two  
documents indexed above:  
On the other hand, if I do a term query on "material" for "card", I  
get zero results back.

curl -XGET [http://127.0.0.1:9200/craft/project/\_search](http://127.0.0.1:9200/craft/project/_search) -d '  
{  
"query" : {  
"filtered" : {  
"query" : {  
"term" : { "kiddo" : "wendy" }  
},  
"filter" : {  
"term" : {"category" : "art\_box"}  
}  
}  
}  
}  
'

=\> 0 results

curl -XGET [http://127.0.0.1:9200/craft/project/\_search](http://127.0.0.1:9200/craft/project/_search) -d '  
{  
"query" : {  
"filtered" : {  
"query" : {  
"term" : { "kiddo" : "wendy" }  
},  
"filter" : {  
"term" : {"category" : "art"}  
}  
}  
}  
}  
'

=\> 2 results

curl -XGET [http://127.0.0.1:9200/craft/project/\_search](http://127.0.0.1:9200/craft/project/_search) -d '  
{  
"query" : {  
"filtered" : {  
"query" : {  
"term" : { "kiddo" : "wendy" }  
},  
"filter" : {  
"term" : {"material" : "cardboard"}  
}  
}  
}  
}  
'

=\> 1 result

curl -XGET [http://127.0.0.1:9200/craft/project/\_search](http://127.0.0.1:9200/craft/project/_search) -d '  
{  
"query" : {  
"filtered" : {  
"query" : {  
"term" : { "kiddo" : "wendy" }  
},  
"filter" : {  
"term" : {"material" : "card"}  
}  
}  
}  
}  
'

=\> 0 result

I'd appreciate any pointers as to what the underlying mechanism is, as  
well as how to do a match against a field like "art\_box".

Thanks!  
Katrina

---

<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, 4:13am UTC](https://discuss.elastic.co/t/underscores-in-search-term/3793/2 "2017-07-06T04:13:41Z")

</div>


