Why are you creating a JSON object for the query string query? You can
create a query builder object directly. Look at the same Java code on the
Elasticsearch site:
Elasticsearch Platform — Find real-time answers at scale | Elastic
Instead of the term query, substitute a QueryStringQueryBuilder. Perhaps
the performance degradation is coming from the serializing/deserializing of
the JSON object.
I have to use the JSON object because the query is dynamic and sent by the
client.
Default search type is QUERY_THEN_FETCH. Using DFS will have some
performance impact, but in my testing it is negligible. Also, are you sure
you want DFS_QUERY*AND*FETCH?
I've changed to QUERY_THEN_FETCH, but didn't work!
I calculated the time when calling the request. Like:
long time = System.currentTimeMillis();
SearchResponse response = request.execute().actionGet();
time = System.currentTimeMillis() - time;
2014-05-19 15:49 GMT-03:00 Ivan Brusic ivan@brusic.com:
Why are you creating a JSON object for the query string query? You can
create a query builder object directly. Look at the same Java code on the
Elasticsearch site:
Elasticsearch Platform — Find real-time answers at scale | Elastic
Instead of the term query, substitute a QueryStringQueryBuilder. Perhaps
the performance degradation is coming from the serializing/deserializing of
the JSON object.
Default search type is QUERY_THEN_FETCH. Using DFS will have some
performance impact, but in my testing it is negligible. Also, are you sure
you want DFS_QUERY*AND*FETCH?
--
Ivan
On Mon, May 19, 2014 at 11:25 AM, Sávio S. Teles de Oliveira <
savio.teles@cuia.com.br> wrote:
Yes, the code is bellow:
String query = ""query": {"query_string": {"default_operator":
"AND","query": "new"}}";
JSONObject jsonObject = new JSONObject(query);
String jsonQuery = jsonObject.get("query").toString();
TermFilterBuilder termFilter = FilterBuilders.termFilter("state", "NY");
FacetBuilder facetBuilder =
FacetBuilders.termsFacet("f").field("city").size(10);
facetBuilder.facetFilter(termFilter);
SearchRequestBuilder request = client.prepareSearch("cities");
request.setQuery(QueryBuilders.wrapperQuery(jsonQuery));
request.addFacet(facetBuilder).setTypes(ATTR).setSearchType(SearchType.DFS_QUERY_AND_FETCH).setFrom(0).setSize(0);
SearchResponse response = request.execute().actionGet();
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAFKmhPs_J2cERAobLMsKo_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.comhttps://groups.google.com/d/msgid/elasticsearch/CAFKmhPs_J2cERAobLMsKo_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/h3g3cb2mGJM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQChYR2YFJEvO_G6LwcoULDfQRNBbuVFF5qnkaEYwAc2jQ%40mail.gmail.comhttps://groups.google.com/d/msgid/elasticsearch/CALY%3DcQChYR2YFJEvO_G6LwcoULDfQRNBbuVFF5qnkaEYwAc2jQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.
--
Atenciosamente,
Sávio S. Teles de Oliveira
voice: +55 62 9136 6996
http://br.linkedin.com/in/savioteles
Mestrando em Ciências da Computação - UFG
Arquiteto de Software
CUIA Internet Brasil
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAFKmhPsUD7YGbq__Y%2B6hPwu8%2By3rC6O%2By9w2vq2fpaFMwOkuYg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.