# Term search on URL literal doesn't match

**URL:** <https://discuss.elastic.co/t/term-search-on-url-literal-doesnt-match/6215>\
**Category:** Elasticsearch\
**Created:** [December 22, 2011, 12:42am UTC](https://discuss.elastic.co/t/term-search-on-url-literal-doesnt-match/6215 "2011-12-22T00:42:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allan\_Caffee](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Allan\_Caffee](https://discuss.elastic.co/u/Allan_Caffee)\
**Post date:** [December 22, 2011, 12:42am UTC](https://discuss.elastic.co/t/term-search-on-url-literal-doesnt-match/6215/1 "2011-12-22T00:42:46Z")

</div>

I'm having a problem doing a term query for documents that have a literal  
match on a string containing a URL. Here's a gist demonstrating the  
issue: [https://gist.github.com/1508383](https://gist.github.com/1508383)

The query was done on a fresh install of ElasticSearch version 0.18.5. Any  
idea what I'm doing wrong here?

--  
Allan

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 22, 2011, 1:01am UTC](https://discuss.elastic.co/t/term-search-on-url-literal-doesnt-match/6215/2 "2011-12-22T01:01:31Z")

</div>

By default, the standard analyzer breaks a url into several tokens, and  
does not keep it as a single token. Since term query is provided with a  
term (there is no analysis process on the text) it will not match.

You have two option, either mark the url field in the mapping as "index" :  
"not\_analyzed", and then the term query will work, or use text query, which  
will break the url into several terms on the search side. The second option  
does mean that you will also possibly find "non exact" matches.

If you want to combine the two worlds, use multi field mapping (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html))  
to have the url analyzed and not analyzed, and then choose on which field  
to search based on your use case.

On Thu, Dec 22, 2011 at 2:42 AM, Allan Caffee [allan.caffee@gmail.com](mailto:allan.caffee@gmail.com)wrote:

> I'm having a problem doing a term query for documents that have a literal  
> match on a string containing a URL. Here's a gist demonstrating the issue:  
> [ElasticSearch (version 0.18.5) term query for literal url match · GitHub](https://gist.github.com/1508383)
> 
> The query was done on a fresh install of Elasticsearch version 0.18.5.  
> Any idea what I'm doing wrong here?
> 
> --  
> Allan

---

<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, 3:44am UTC](https://discuss.elastic.co/t/term-search-on-url-literal-doesnt-match/6215/3 "2017-07-06T03:44:38Z")

</div>


