Yea, its a problem where the source itself gets overwritten, I will fix that, for now, you can use setExtraSource.
On Tuesday, January 31, 2012 at 4:06 AM, Prashanth wrote:
Hello all,
I have started using Elasticsearch recently. I am facing a
problem using Java API for free text search.
If I try using QueryBuilder to build the query, result is what is
expected.
SearchResponse response = esClient
.prepareSearch(getDefaultIndexName(client))
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setQuery(queryString("freetext")).execute().actionGet(); -> This
is working fine, resulting the data properly.
As per our design, jSON will be formed in the UI Layer and in the
BL layer we need to use the already formed JSON to search elastic
search.
With HTTP approach, result is same as above.
Query Json used is : {"query":{"query_string":{"query":"freetext"}}}
But when I use the same JSON in java API, result is different.
Following is the piece of code which is written in java to use json
query.
SearchResponse response = esClient
.prepareSearch(getDefaultIndexName(client))
.setSource(queryJson).execute().actionGet(); // Query Json is
having above mentioned query.
In this case, the result is different.( Returning all data without
applying search params)
Please let me know what is being done in a wrong way.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.