Continuing the discussion from Java Client slower than http :
Hey guys
I'm having the same issue where a query using the native JAVA client takes much longer than in the REST api (instead of 15 ms, it takes 2500 ms).
I made some checks and it looks like the Execute() part is taking about 40 ms and the get() or actionGet() parts take the rest of the time.
my query (which is derived from the "SearchRequestBuilder.ToString() is":
POST common/performance/_search
{
"from" : 0,
"size" : 1400,
"query" : {
"query_string" : {
"query" : "7",
"default_field" : "cluster"
}
},
"post_filter" : {
"range" : {
"timestamp" : {
"from" : 0,
"to" : 1538486562000,
"include_lower" : true,
"include_upper" : true
}
}
},
"explain" : false,
"sort" : [ {
"timestamp" : {
"order" : "desc"
}
} ]
}
any help will be appreciated.
Thanks
Asaf
We are currently using TransportClient and observing that query response times are considerably slower than using http (through sense plugin). Below is code snippet for initializing TransportClient:
> void createClient(Map<String, String> props) {
Settings settings = ImmutableSettings.settingsBuilder().put(props).build();
transportClient = new TransportClient(settings);
String[] hosts = getTransportHosts().split(",");
for (String host : hosts) {
int index = host.indexOf(COLON);
String hostname = host.substring(0, index);
String port = host.substring(index + 1);
transportClient.addTransportAddress(new InetSocketTransportAddress(hostname.trim(), Integer.parseInt(port.trim())));
}
}
Map<String, String> createClientConfigSettings() {
Map<String, String> clientProperties = new HashMap<>();
clientProperties.put(CLUSTER_NAME_PROPERTY, getClusterName());
clientProperties.put("client.transport.ping_timeout", "10s");
clientProperties.put("client.transport.nodes_sampler_interval", "10s");
String nodeName = processInstanceName();
clientProperties.put("node.name", nodeName);
return clientProperties;
}
Please advise.
Thanks,
Prateek
dadoonet
(David Pilato)
July 22, 2015, 9:23am
2
execute()
launches the query (asynchronous) and get()
waits for the answer.
What is your exact REST query?
Asaf_Elias:
POST common/performance/_search{ "from" : 0, "size" : 1400, "query" : { "query_string" : { "query" : "7", "default_field" : "cluster" } }, "post_filter" : { "range" : { "timestamp" : { "from" : 0, "to" : 1538486562000, "include_lower" : true, "include_upper" : true } } }, "explain" : false, "sort" : [ { "timestamp" : { "order" : "desc" } } ]}
Hey
The query i'm sending using Sense is:
POST common/performance/_search
{
"from" : 0,
"size" : 1400,
"query" : {
"query_string" : {
"query" : "7",
"default_field" : "cluster"
}
},
"post_filter" : {
"range" : {
"timestamp" : {
"from" : 0,
"to" : 1538486562000,
"include_lower" : true,
"include_upper" : true
}
}
},
"explain" : false,
"sort" : [ {
"timestamp" : {
"order" : "desc"
}
} ]
}
i've just copied the builder.tostring() to Sense and ran it.
Asaf