Hi,
I am trying to serialize the XContentBuilder objects over the write from
the client and regenerate at the server side. At the server side I am
trying
to rebuild the XContentBuilder and bulk seed into the ES server. However I
am not aware of any API where one can rebuild the XContentBuilder from
InputStream.
// Client side code
sendJSONObjects()
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XContentBuilder json1 = XContentFactory.jsonBuilder(bos)
.startObject()
.field("nodeId", 1)
.endObject()
.startObject() // second
object
.field("nodeId", 2)
.endObject();
json1.flush();
bos.close();
byte[] bytes = compressBytes(bos.toByteArray());
SeedData data = new SeedData();
data.setObjects(bytes);
// .... set application data on seed data
// transfer data
}
// Server side
readJSONObjects(SeedData data)
{
bytes [] jsonObjectBytes = decompress(data.getObjects());
// bulk insert into ES server
}
Now how do i create XContentBuilder objects from jsonObjectBytes so that i
can do bulk insert??
thanks
--
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 .
For more options, visit https://groups.google.com/groups/opt_out .
spinscale
(Alexander Reelsen)
June 7, 2013, 7:38am
#2
Hey,
As the XContentBuilder is simply a builder pattern and not a data structure
for serializing, I am not sure you approach works (havent peeked at the
source though).
Alternatively you could use the XContentParser
Map<String, Object> foo =
JsonXContent.jsonXContent.createParser(is).mapAndClose()
Hope this helps (otherwise I most likely got your question wrong),
--Alex
On Thu, Jun 6, 2013 at 8:58 PM, vinod eligeti veligeti999@gmail.com wrote:
Hi,
I am trying to serialize the XContentBuilder objects over the write from
the client and regenerate at the server side. At the server side I am
trying
to rebuild the XContentBuilder and bulk seed into the ES server. However I
am not aware of any API where one can rebuild the XContentBuilder from
InputStream.
// Client side code
sendJSONObjects()
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XContentBuilder json1 = XContentFactory.jsonBuilder(bos)
.startObject()
.field("nodeId", 1)
.endObject()
.startObject() // second
object
.field("nodeId", 2)
.endObject();
json1.flush();
bos.close();
byte[] bytes = compressBytes(bos.toByteArray());
SeedData data = new SeedData();
data.setObjects(bytes);
// .... set application data on seed data
// transfer data
}
// Server side
readJSONObjects(SeedData data)
{
bytes [] jsonObjectBytes = decompress(data.getObjects());
// bulk insert into ES server
}
Now how do i create XContentBuilder objects from jsonObjectBytes so that i
can do bulk insert??
thanks
--
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 .
For more options, visit https://groups.google.com/groups/opt_out .
--
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 .
For more options, visit https://groups.google.com/groups/opt_out .
jprante
(Jörg Prante)
June 7, 2013, 7:50am
#3
You know ES provides already an API for that with the transport client
(I call it the Java Transport API?)
Jörg
Am 06.06.2013 20:58, schrieb vinod eligeti:
I am trying to serialize the XContentBuilder objects over the write
from the client and regenerate at the server side.
--
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 .
For more options, visit https://groups.google.com/groups/opt_out .
Jorg,
Transport API directly push docs into the ES servers however, I need to do
some business logic before I push into the ES servers.
On Fri, Jun 7, 2013 at 12:50 AM, Jörg Prante joergprante@gmail.com wrote:
You know ES provides already an API for that with the transport client (I
call it the Java Transport API?)
Jörg
Am 06.06.2013 20:58, schrieb vinod eligeti:
I am trying to serialize the XContentBuilder objects over the write from
the client and regenerate at the server side.
--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/-**Yr4q3bvBeM/unsubscribe?hl=en-**UShttps://groups.google.com/d/topic/elasticsearch/-Yr4q3bvBeM/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@**googlegroups.com elasticsearch%2Bunsubscribe@googlegroups.com
.
For more options, visit https://groups.google.com/**groups/opt_out https://groups.google.com/groups/opt_out
.
--
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 .
For more options, visit https://groups.google.com/groups/opt_out .