java - ElasticSearch:Current context not an ARRAY but OBJECT when trying to index an array -
i have scala mutable set want index in elasticsearch array way in doing throwing me error here code
var genreidset = scala.collection.mutable.set[int]() genreidset+=1 genreidset+=2 genreidset+=3 val bulkrequest=client.preparebulk() bulkrequest.add(client.prepareindex("testdb","test","123") .setsource(mymethod) ) val bulkresponse =bulkrequest.execute().actionget() def mymethod: xcontentbuilder={ def json={jsonbuilder().startobject()} json.field("uuid","123") json.startarray("genreidset") for(n<-genreidset) { json.value(n) } json.endarray() json.endobject() }
but gives me error
-current context not array object org.elasticsearch.common.jackson.core.jsongenerationexception: current context not array object @ org.elasticsearch.common.jackson.core.jsongenerator._reporterror(jsongenerator.java:1487) ~[elasticsearch-1.5.0.jar:na] @ org.elasticsearch.common.jackson.core.json.utf8jsongenerator.writeendarray(utf8jsongenerator.java:298) ~[elasticsearch-1.5.0.jar:na] @ org.elasticsearch.common.xcontent.json.jsonxcontentgenerator.writeendarray(jsonxcontentgenerator.java:74) ~[elasticsearch-1.5.0.jar:na] @ org.elasticsearch.common.xcontent.xcontentbuilder.endarray(xcontentbuilder.java:233) ~[elasticsearch-1.5.0.jar:na] @ models.artistmodels.artistmodelsesreadwrite.artistimplstorees.mymethod$1(artistimplstorees.scala:41) ~[classes/:na] @ models.artistmodels.artistmodelsesreadwrite.artistimplstorees.writees(artistimplstorees.scala:60) ~[classes/:na] @ models.artistmodels.artistmodelsesreadwrite.artistimplwritetoesactor$$anonfun$receive$1.applyorelse(artistimplwritetoesactor.scala:21) ~[classes/:na]
please me making mistake
you can try doing
var genreidset = scala.collection.mutable.set[int]() genreidset+=1 genreidset+=2 genreidset+=3 var xb:xcontentbuilder=xcontentfactory.jsonbuilder().startobject().field("uuid",artistimpl.getuuid) xb.startarray("getgenreidset") for(n<-genreidset) { xb.value(n) } xb.endarray() xb.endobject() val bulkrequest=client.preparebulk() bulkrequest.add(client.prepareindex("testdb","test","123") .setsource(xb) ) val bulkresponse =bulkrequest.execute().actionget()
Comments
Post a Comment