How to index and search for URLs?


(Barak Yaish) #1

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
). 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" );

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!


(system) #2