Search query isn't working for Elasticsearch 5.0 -
i have groovy script work elasticsearch 2.3.2. made changes index structure. i'm able create index , push results elasticsearch 5.0. when try extract total count of runid won't work. please find groovy script below:
static def extractrunidsforrelease(string baseurl,string project,string release) { try { def response_body = null def response_header = null def query = '{"size":0,"aggs":{"langs":{"terms":{ "field":"runid","size": 0}}}}' def bodyquery = new jsonslurper().parsetext(query) def rel = "release:" + release def params = [q:rel] def http = new httpbuilder(baseurl) http.request(method.post) { uri.path = project + '/run/_search' println "uri.path::" +uri.path uri.query = params println "uri.query" +uri.query requestcontenttype = contenttype.json body = bodyquery println "body:" +body headers.'accept-encoding' = 'gzip,deflate' headers.'cookie' = 'jsessionid=934ed773c47d81c74c63beafe1d6ca1b' response.success = { resp, reader -> if (reader != null) { response_body = reader.aggregations.langs.buckets println "response_body:::"+response_body } } response.failure = { resp, reader -> response_header = null response_body = null println "request failed : [uri : ${path}, status: ${resp.status}]" } } return response_body } catch (groovyx.net.http.httpresponseexception ex) { ex.printstacktrace() return null } catch (java.net.connectexception ex) { ex.printstacktrace() return null } }
the below search query used in script
{"size":0,"aggs":{"langs":{"terms":{ "field":"runid","size": 0}}
returns below result version 2.0
{ "took": 2, "timed_out": false, "_shards": { "total": 2, "successful": 2, "failed": 0 }, "hits": { "total": 4, "max_score": 0, "hits": [] }, "aggregations": { "langs": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "1", "doc_count": 4 } ] } } }
index structure:
{\"settings\":{\"number_of_shards\":2,\"number_of_replicas\":0},\"mappings\":{\"run\":{\"properties\":{\"70 percentile\":{\"type\":\"float\"},\"80 percentile\":{\"type\":\"float\"},\"85 percentile\":{\"type\":\"float\"},\"95 percentile\":{\"type\":\"float\"},\"90 percentile\":{\"type\":\"float\"},\"average\":{\"type\":\"float\"},\"fail\":{\"type\":\"string\"},\"maximum\":{\"type\":\"float\"},\"minimum\":{\"type\":\"float\"},\"pass\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"projectname\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"runid\":{\"type\":\"string\"},\"virtualusers\":{\"type\":\"string\"},\"release\":{\"type\":\"string\"},\"buildnumber\":{\"type\":\"string\"},\"starttime\":{\"type\":\"string\"},\"endtime\":{\"type\":\"string\"},\"stddeviation\":{\"type\":\"string\"},\"testname\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"transactionname\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"baseline\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"slaviolationcount\":{\"type\":\"float\"}}}}}"
but same search query isn't working version 5.0 , shown below error:
[thread-63] warn groovyx.net.http.httpbuilder - error parsing 'application/json; charset=utf-8' response groovy.json.jsonexception: unable determine current character, not string, number, array, or object current character read '?' int value of 65533 unable determine current character, not string, number, array, or object line number 1 index number 1 ? @ groovy.json.internal.jsonparserchararray.decodevalueinternal(jsonparserchararray.java:206) @ groovy.json.internal.jsonparserchararray.decodevalue(jsonparserchararray.java:157) @ groovy.json.internal.jsonparserchararray.decodefromchars(jsonparserchararray.java:45) @ groovy.json.internal.jsonparserchararray.parse(jsonparserchararray.java:385) @ groovy.json.internal.basejsonparser.parse(basejsonparser.java:124) @ groovy.json.jsonslurper.parse(jsonslurper.java:218) @ groovyx.net.http.parserregistry.parsejson(parserregistry.java:280) @ sun.reflect.generatedmethodaccessor355.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.codehaus.groovy.reflection.cachedmethod.invoke(cachedmethod.java:90) @ groovy.lang.metamethod.domethodinvoke(metamethod.java:324) @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1207) @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1074) @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1016) @ groovy.lang.closure.call(closure.java:423) @ groovy.lang.closure.call(closure.java:439) @ groovyx.net.http.httpbuilder.parseresponse(httpbuilder.java:560) @ groovyx.net.http.httpbuilder$1.handleresponse(httpbuilder.java:489) @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:1070) @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:1044) @ groovyx.net.http.httpbuilder.dorequest(httpbuilder.java:515) @ groovyx.net.http.httpbuilder.dorequest(httpbuilder.java:434) @ groovyx.net.http.httpbuilder.request(httpbuilder.java:366) @ groovyx.net.http.httpbuilder$request$0.call(unknown source) @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:110) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:130) @ commonutils.extractrunidsforrelease(updated.groovy:889) @ commonutils$extractrunidsforrelease$6.call(unknown source) @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:110) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:138) @ commonutils.comparisonreportlasttworun(updated.groovy:946) @ commonutils$comparisonreportlasttworun$5.call(unknown source) @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:110) @ updated.run(updated.groovy:248) @ groovy.lang.groovyshell.runscriptormainortestorrunnable(groovyshell.java:261) @ groovy.lang.groovyshell.run(groovyshell.java:522) @ groovy.lang.groovyshell.run(groovyshell.java:501) @ groovy.lang.groovyshell.run(groovyshell.java:168) @ groovy.lang.groovyshell$run$0.call(unknown source) @ groovy.ui.console$_runscriptimpl_closure17.docall(console.groovy:977) @ groovy.ui.console$_runscriptimpl_closure17.docall(console.groovy) @ sun.reflect.generatedmethodaccessor270.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.codehaus.groovy.reflection.cachedmethod.invoke(cachedmethod.java:90) @ groovy.lang.metamethod.domethodinvoke(metamethod.java:324) @ org.codehaus.groovy.runtime.metaclass.closuremetaclass.invokemethod(closuremetaclass.java:292) @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1016) @ groovy.lang.closure.call(closure.java:423) @ groovy.lang.closure.call(closure.java:417) @ groovy.lang.closure.run(closure.java:504) @ java.lang.thread.run(thread.java:748) groovyx.net.http.responseparseexception: bad request @ groovyx.net.http.httpbuilder$1.handleresponse(httpbuilder.java:495) @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:1070) @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:1044) @ groovyx.net.http.httpbuilder.dorequest(httpbuilder.java:515) @ groovyx.net.http.httpbuilder.dorequest(httpbuilder.java:434) @ groovyx.net.http.httpbuilder.request(httpbuilder.java:366) @ groovyx.net.http.httpbuilder$request$0.call(unknown source) @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:110) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:130) @ commonutils.extractrunidsforrelease(updated.groovy:889) @ commonutils$extractrunidsforrelease$6.call(unknown source) @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:110) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:138) @ commonutils.comparisonreportlasttworun(updated.groovy:946) @ commonutils$comparisonreportlasttworun$5.call(unknown source) @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:110) @ updated.run(updated.groovy:248) @ groovy.lang.groovyshell.runscriptormainortestorrunnable(groovyshell.java:261) @ groovy.lang.groovyshell.run(groovyshell.java:522) @ groovy.lang.groovyshell.run(groovyshell.java:501) @ groovy.lang.groovyshell.run(groovyshell.java:168) @ groovy.lang.groovyshell$run$0.call(unknown source) @ groovy.ui.console$_runscriptimpl_closure17.docall(console.groovy:977) @ groovy.ui.console$_runscriptimpl_closure17.docall(console.groovy) @ sun.reflect.generatedmethodaccessor270.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.codehaus.groovy.reflection.cachedmethod.invoke(cachedmethod.java:90) @ groovy.lang.metamethod.domethodinvoke(metamethod.java:324) @ org.codehaus.groovy.runtime.metaclass.closuremetaclass.invokemethod(closuremetaclass.java:292) @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1016) @ groovy.lang.closure.call(closure.java:423) @ groovy.lang.closure.call(closure.java:417) @ groovy.lang.closure.run(closure.java:504) @ java.lang.thread.run(thread.java:748) caused by: groovy.json.jsonexception: unable determine current character, not string, number, array, or object
am missing out on something. kindly me search query es 5.0. helpful. in advance
Comments
Post a Comment