# Searching on terms with dashes

**URL:** <https://discuss.elastic.co/t/searching-on-terms-with-dashes/4251>\
**Category:** Elasticsearch\
**Created:** [April 18, 2011, 8:28pm UTC](https://discuss.elastic.co/t/searching-on-terms-with-dashes/4251 "2011-04-18T20:28:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Diephouse](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@Dan\_Diephouse](https://discuss.elastic.co/u/Dan_Diephouse)\
**Post date:** [April 18, 2011, 8:28pm UTC](https://discuss.elastic.co/t/searching-on-terms-with-dashes/4251/1 "2011-04-18T20:28:14Z")

</div>

We have a document that is basically like so:

{  
"\_index" : "foo",  
"\_type" : "log",  
"\_id" : "6fWTxYKQT1GVD05o5arkFg",  
"\_score" : 1.0, "\_source" :  
{"timestamp":"2011-04-17T23:39:00.551Z","host":"ip-10-85-67-73.ec2.internal","priority":"INFO","message":  
{"text":"....\n"},"fields":{"domain":"[foo-bar.foo.com](http://foo-bar.foo.com)"}}  
}

I'm trying to do an exact search based on the domain. For example:

curl [http://localhost:9200/ion/\_search?pretty=true](http://localhost:9200/ion/_search?pretty=true) -d '{ "query" :  
{ "term" : { "fields.domain" : "[foo-bar.foo.com](http://foo-bar.foo.com)" } } }'

However, this just returns an empty result. If I remove the dash, it  
works. What can I do here to be able to search with dashes???

Dan

---

<div class="post-metadata">

**Author:** ![David\_Williams](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@David\_Williams](https://discuss.elastic.co/u/David_Williams)\
**Post date:** [April 18, 2011, 9:02pm UTC](https://discuss.elastic.co/t/searching-on-terms-with-dashes/4251/2 "2011-04-18T21:02:05Z")

</div>

change the mapping for the field like so (quotes removed for readability):

domain:{type:string, index:not\_analyzed}

this page describes the details:

> **[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.

& this one might be useful too:

> **[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.

-david

On Mon, Apr 18, 2011 at 1:28 PM, Dan Diephouse [diephouse@gmail.com](mailto:diephouse@gmail.com) wrote:

> We have a document that is basically like so:
> 
> {  
> "\_index" : "foo",  
> "\_type" : "log",  
> "\_id" : "6fWTxYKQT1GVD05o5arkFg",  
> "\_score" : 1.0, "\_source" :  
> {"timestamp":"2011-04-17T23:39:00.551Z","host":"ip-10-85-67-73.ec2.internal","priority":"INFO","message":  
> {"text":"....\n"},"fields":{"domain":"[foo-bar.foo.com](http://foo-bar.foo.com)"}}  
> }
> 
> I'm trying to do an exact search based on the domain. For example:
> 
> curl [http://localhost:9200/ion/\_search?pretty=true](http://localhost:9200/ion/_search?pretty=true) -d '{ "query" :  
> { "term" : { "fields.domain" : "[foo-bar.foo.com](http://foo-bar.foo.com)" } } }'
> 
> However, this just returns an empty result. If I remove the dash, it  
> works. What can I do here to be able to search with dashes???
> 
> Dan

---

<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:08am UTC](https://discuss.elastic.co/t/searching-on-terms-with-dashes/4251/3 "2017-07-06T04:08:10Z")

</div>


