# How to index and search for URLs?

**URL:** <https://discuss.elastic.co/t/how-to-index-and-search-for-urls/3783>\
**Category:** Elasticsearch\
**Created:** [January 16, 2011, 2:26pm UTC](https://discuss.elastic.co/t/how-to-index-and-search-for-urls/3783 "2011-01-16T14:26:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barak\_Yaish](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Barak\_Yaish](https://discuss.elastic.co/u/Barak_Yaish)\
**Post date:** [January 16, 2011, 2:26pm UTC](https://discuss.elastic.co/t/how-to-index-and-search-for-urls/3783/1 "2011-01-16T14:26:03Z")

</div>

I'm using the JAVA API to index the documents, one of the properties  
is a URL (for example: [http://groups.google.com/a/elasticsearch.com/group/users/post](http://groups.google.com/a/elasticsearch.com/group/users/post)  
). When trying to search the index by url, I get zero results in the  
response:

XContentQueryBuilder xcqb = QueryBuilders.fieldQuery( "url", "http://  
[groups.google.com/a/elasticsearch.com/group/users/post](http://groups.google.com/a/elasticsearch.com/group/users/post)" );

SearchResponse response = client.prepareSearch("edgecache")  
.setSearchType(SearchType.DEFAULT)  
.setQuery(xcqb)  
.setFrom(0).setSize(60).setExplain(true).execute().actionGet();

System.out.println( response.getHits() ); //empty hits

I guess this is due the special chars appear (: or ? when there is  
query string, etc.). I didn't understand from the docs how should one  
configure the proper analyzer, can you please help with detailed  
example? Is this configurable by the JAVA API or environment vars?

Thanks!

---

<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/how-to-index-and-search-for-urls/3783/2 "2017-07-06T04:13:49Z")

</div>


