Performance issue for search query is taking taking around 5 to 6 secs

Hi All,

 we had created the index of 130 million data with 5 shards and four 

nodes.we had written the query with query string passing around 100 search
values with space separate and passing the results to another query.total
it is taking around 5 to 6 secs to complete get the results for two
queres.Is there any performance improvent suggestion.Below is the query i
am running

qb =
QueryBuilders.queryString(QotConstants.SERIAL_NUMBER+"("+serialNumbers+")");

SearchResponse response =
elasticClient.prepareSearch("index").setQuery(qb)

.setSearchType(SearchType.QUERY_THEN_FETCH).addField(QotConstants.INSTANCE_ID).setFrom(0)
.setSize(20000)
.execute()
.actionGet();
results = response.getHits().hits();
String instanceQueryString = "";
int i=0;
for (SearchHit hit : results) {
instanceQueryString =instanceQueryString+"
"+hit.getFields().get(QotConstants.INSTANCE_ID).getValue();

}
List<Map<String,Object>> hits = new ArrayList<Map<String,Object>>();
if(!instanceQueryString.equals("")){
response = elasticClient.prepareSearch("index")

.setQuery(QueryBuilders.queryString("PARENT_INSTANCE_ID:("+instanceQueryString.trim()+")"))
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setFrom(0).setSize(200)
.execute()
.actionGet();

results = response.getHits().hits();
for (SearchHit hit : results) {
hits.add(hit.getSource());
}
}

Thanks for you help in advance

--
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/1ad89fe6-f4ad-429f-9fa8-45b6607b93ac%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

It sounds like you don't really need scoring so you might want to use
filters instead of the query_string query. Perhaps you can try the terms
filter instead. Maybe something like this:

  String[] terms = { "sn1", "sn2" };
  QueryBuilder q = 

QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
FilterBuilders.termsFilter("sn", terms));

Here is more info on why filters are better speedwise:

--
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/5c9e92e8-0404-4be2-b62b-f1daca44ddaf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Binh.

I had tried with using the Term Filter .I am seeing little performance
improvement but not as expected (expected 1sec)

Any pointers.

Thanks

On Wednesday, January 29, 2014 1:29:31 PM UTC-8, Binh Ly wrote:

It sounds like you don't really need scoring so you might want to use
filters instead of the query_string query. Perhaps you can try the terms
filter instead. Maybe something like this:

  String[] terms = { "sn1", "sn2" };
  QueryBuilder q = 

QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
FilterBuilders.termsFilter("sn", terms));

Here is more info on why filters are better speedwise:

Elasticsearch Platform — Find real-time answers at scale | Elastic

--
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/d9088182-282e-492b-a6b6-8c49204014a3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.