Native Java API is slower than the REST one


(Asaf Elias) #1

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


(David Pilato) #2

execute() launches the query (asynchronous) and get() waits for the answer.

What is your exact REST query?


(Asaf Elias) #3

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


(system) #4