# Search For Url returning no results

**URL:** <https://discuss.elastic.co/t/search-for-url-returning-no-results/6939>\
**Category:** Elasticsearch\
**Created:** [March 8, 2012, 2:12am UTC](https://discuss.elastic.co/t/search-for-url-returning-no-results/6939 "2012-03-08T02:12:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Carvell](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@Ian\_Carvell](https://discuss.elastic.co/u/Ian_Carvell)\
**Post date:** [March 8, 2012, 2:12am UTC](https://discuss.elastic.co/t/search-for-url-returning-no-results/6939/1 "2012-03-08T02:12:22Z")

</div>

Hello,

We are trying to search for urls within text in a field. For example  
we have a field called content that has the value "use [http://elasticsearch.org](http://elasticsearch.org)  
for search and email [kimchy@elasticsearch.org](mailto:kimchy@elasticsearch.org) for questions."

We are using the following configuration for our elasticsearch.yml:

index:  
analysis:  
analyzer:  
default\_index:  
filter: [standard, lowercase]  
tokenizer: uax\_url\_email  
default\_search:  
tokenizer: uax\_url\_email  
filter: [standard, lowercase]

With these settings we are able to search for [kimchy@elasticsearch.org](mailto:kimchy@elasticsearch.org)  
and get a result but when we search for [http://elasticsearch.org](http://elasticsearch.org) we  
get no results.

We have used curl to verify the results of analyze and see that  
[http://elasticsearch.org](http://elasticsearch.org) and [kimchy@elasticsearch.org](mailto:kimchy@elasticsearch.org) each geneate a  
single token:

curl [http://localhost:9200/elastic\_searchable/\_analyze?text=http://elasticsearch.org](http://localhost:9200/elastic_searchable/_analyze?text=http://elasticsearch.org)  
{"tokens":[{"token":"[http://elasticsearch.org](http://elasticsearch.org)","start\_offset":  
0,"end\_offset":24,"type":"","position":1}]}

curl [http://localhost:9200/elastic\_searchable/\_analyze?text=kimchy@elasticsearch.org](http://localhost:9200/elastic_searchable/_analyze?text=kimchy@elasticsearch.org)  
{"tokens":[{"token":"kimchy@elasticsearch.org","start\_offset":  
0,"end\_offset":24,"type":"","position":1}]}

We aren't sure why the url search doesn't work. Any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 8, 2012, 7:51am UTC](https://discuss.elastic.co/t/search-for-url-returning-no-results/6939/2 "2012-03-08T07:51:30Z")

</div>

On Thu 08 Mar 2012 03:12:22 CET, Ian Carvell wrote:

> Hello,
> 
> We are trying to search for urls within text in a field. For example  
> we have a field called content that has the value "use [http://elasticsearch.org](http://elasticsearch.org)  
> for search and email [kimchy@elasticsearch.org](mailto:kimchy@elasticsearch.org) for questions."
> 
> We are using the following configuration for our elasticsearch.yml:
> 
> index:  
> analysis:  
> analyzer:  
> default\_index:  
> filter: [standard, lowercase]  
> tokenizer: uax\_url\_email  
> default\_search:  
> tokenizer: uax\_url\_email  
> filter: [standard, lowercase]
> 
> With these settings we are able to search for [kimchy@elasticsearch.org](mailto:kimchy@elasticsearch.org)  
> and get a result but when we search for [http://elasticsearch.org](http://elasticsearch.org) we  
> get no results.
> 
> We have used curl to verify the results of analyze and see that  
> [http://elasticsearch.org](http://elasticsearch.org) and [kimchy@elasticsearch.org](mailto:kimchy@elasticsearch.org) each geneate a  
> single token:
> 
> curl [http://localhost:9200/elastic\_searchable/\_analyze?text=http://elasticsearch.org](http://localhost:9200/elastic_searchable/_analyze?text=http://elasticsearch.org)  
> {"tokens":[{"token":"[http://elasticsearch.org](http://elasticsearch.org)","start\_offset":  
> 0,"end\_offset":24,"type":"","position":1}]}
> 
> curl [http://localhost:9200/elastic\_searchable/\_analyze?text=kimchy@elasticsearch.org](http://localhost:9200/elastic_searchable/_analyze?text=kimchy@elasticsearch.org)  
> {"tokens":[{"[token":"kimchy@elasticsearch.org](mailto:token%22:%22kimchy@elasticsearch.org)","start\_offset":  
> 0,"end\_offset":24,"type":"","position":1}]}
> 
> We aren't sure why the url search doesn't work. Any ideas?
> 
> Thanks

Probably something to do with how you are searching. I suggest gisting  
a small recreation of the issue: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)

---

<div class="post-metadata">

**Author:** ![Ian\_Carvell](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@Ian\_Carvell](https://discuss.elastic.co/u/Ian_Carvell)\
**Post date:** [March 8, 2012, 7:46pm UTC](https://discuss.elastic.co/t/search-for-url-returning-no-results/6939/3 "2012-03-08T19:46:55Z")

</div>

Here is a gist showing what we are doing: [Elasticsearch url search · GitHub](https://gist.github.com/2002929)

On Mar 7, 11:51 pm, Clinton Gormley [cl...@traveljury.com](mailto:cl...@traveljury.com) wrote:

> On Thu 08 Mar 2012 03:12:22 CET, Ian Carvell wrote:
> 
> > Hello,
> 
> > We are trying to search for urls within text in a field. For example  
> > we have a field called content that has the value "usehttp://elasticsearch.org  
> > for search and email [kim...@elasticsearch.org](mailto:kim...@elasticsearch.org) for questions."
> 
> > We are using the following configuration for our elasticsearch.yml:
> 
> > index:  
> > analysis:  
> > analyzer:  
> > default\_index:  
> > filter: [standard, lowercase]  
> > tokenizer: uax\_url\_email  
> > default\_search:  
> > tokenizer: uax\_url\_email  
> > filter: [standard, lowercase]
> 
> > With these settings we are able to search for [kim...@elasticsearch.org](mailto:kim...@elasticsearch.org)  
> > and get a result but when we search forhttp://elasticsearch.orgwe  
> > get no results.
> 
> > We have used curl to verify the results of analyze and see that  
> > [http://elasticsearch.organd](http://elasticsearch.organd) [kim...@elasticsearch.org](mailto:kim...@elasticsearch.org) each geneate a  
> > single token:
> 
> > curlhttp://localhost:9200/elastic\_searchable/\_analyze?text=[http://elastic](http://elastic)...  
> > {"tokens":[{"token":"[http://elasticsearch.org](http://elasticsearch.org)","start\_offset":  
> > 0,"end\_offset":24,"type":"","position":1}]}
> 
> > curl [http://localhost:9200/elastic\_searchable/\_analyze?text=kim](http://localhost:9200/elastic_searchable/_analyze?text=kim)[...@elasticsearch.org](mailto:...@elasticsearch.org)  
> > {"tokens":[{"[token":"kim...@elasticsearch.org](mailto:token%22:%22kim...@elasticsearch.org)","start\_offset":  
> > 0,"end\_offset":24,"type":"","position":1}]}
> 
> > We aren't sure why the url search doesn't work. Any ideas?
> 
> > Thanks
> 
> Probably something to do with how you are searching. I suggest gisting  
> a small recreation of the issue:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 9, 2012, 10:57am UTC](https://discuss.elastic.co/t/search-for-url-returning-no-results/6939/4 "2012-03-09T10:57:28Z")

</div>

On Thu, 2012-03-08 at 11:46 -0800, Ian Carvell wrote:

> Here is a gist showing what we are doing: [Elasticsearch url search · GitHub](https://gist.github.com/2002929)

The problem is that you are using the Lucene query parser on the search  
string. And it interprets 'http:' as: search in field 'http'

This query works:

curl [http://localhost:9200/pages/\_search?q=http\\://elasticsearch.org](http://localhost:9200/pages/_search?q=http%5C%5C://elasticsearch.org)

Alternatively, just use a 'text' query:

curl -XGET '[http://127.0.0.1:9200/pages/\_search?pretty=1](http://127.0.0.1:9200/pages/_search?pretty=1)' -d '  
{  
"query" : {  
"text" : {  
"\_all" : "[http://elasticsearch.org](http://elasticsearch.org)"  
}  
}  
}  
'

clint

---

<div class="post-metadata">

**Author:** ![Ian\_Carvell](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@Ian\_Carvell](https://discuss.elastic.co/u/Ian_Carvell)\
**Post date:** [March 14, 2012, 4:58am UTC](https://discuss.elastic.co/t/search-for-url-returning-no-results/6939/5 "2012-03-14T04:58:25Z")

</div>

That was our problem, thanks very much for your help with this.

On Friday, March 9, 2012 2:57:28 AM UTC-8, Clinton Gormley wrote:

> On Thu, 2012-03-08 at 11:46 -0800, Ian Carvell wrote:
> 
> > Here is a gist showing what we are doing:  
> > [Elasticsearch url search · GitHub](https://gist.github.com/2002929)
> 
> The problem is that you are using the Lucene query parser on the search  
> string. And it interprets 'http:' as: search in field 'http'
> 
> This query works:
> 
> curl [http://localhost:9200/pages/\_search?q=http\\://elasticsearch.org](http://localhost:9200/pages/_search?q=http%5C%5C://elasticsearch.org)
> 
> Alternatively, just use a 'text' query:
> 
> curl -XGET '[http://127.0.0.1:9200/pages/\_search?pretty=1](http://127.0.0.1:9200/pages/_search?pretty=1)' -d '  
> {  
> "query" : {  
> "text" : {  
> "\_all" : "[http://elasticsearch.org](http://elasticsearch.org)"  
> }  
> }  
> }  
> '
> 
> clint

---

<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 5, 2017, 10:23pm UTC](https://discuss.elastic.co/t/search-for-url-returning-no-results/6939/7 "2017-07-05T22:23:51Z")

</div>


