Term search on URL literal doesn't match


(Allan Caffee) #1

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

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

--
Allan


(Shay Banon) #2

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 (
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.comwrote:

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

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

--
Allan


(system) #3