0
votes

I am trying to execute a term query with value being a string which has colon in it. It works fine with the sense plugin.

    GET XX/XX/_search
{
   "query": {
      "term" : { "XX.XX" : "7:140453136:T" }
   }
}

But the same term query doesnt work with java API.

    SearchRequestBuilder response = client.prepareSearch(indexName);
    response.setTypes(indexType);
    response.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
    response.setQuery(QueryBuilders.termQuery("XX.XX", "7:140453136:T"));
    response.setFrom(0).setSize(60).setExplain(true);
    SearchResponse matchallResponse = response.execute().actionGet()

error:

TransportSerializationException[Failed to deserialize response of type [org.elasticsearch.action.search.SearchResponse]]

Caused by: java.lang.ClassNotFoundException: org.apache.lucene.codecs.lucene50.Lucene50DocValuesFormat
  1. in my mapping i had set this field to be not analyzed. so i am sure elasticsearch is not tokenizing it. 2.I am using ES 2.1.1

I see that there is already a question on this. But the solution posted there dosent solve my problem.

1
Does your Java query run for any other value? - uncaught_exception
Yes it works fine with search which doesnt contain :(colon). - Abhi.G
Are you sure the relevant lucene-codecs library is in your classpath? Your syntax looks absolutely fine, the error tells you that the class can't be found though - IanGabes
You are right. i had the latest lucene core libraries in my classpath which doesnt have this class. Then i replaced the lucene core with 5.3.1 and everything works fine now. Dont use lucene core >5.3.1 with ES 2.1.1 is the solution for this problem. Thanks everyone! - Abhi.G
@IanGabes could you write that comment as answer for upvote, and also it will help future readers too - ChintanShah25

1 Answers

0
votes

I had the latest lucene core libraries in my classpath which doesnt have Lucene50DocValuesFormat. I replaced the lucene core with 5.3.1 and everything works fine now. Dont use lucene core >5.3.1 with ES 2.1.1 is the solution for this problem. Thanks everyone! Hope this helps!