You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nesrine <ne...@gmail.com> on 2017/05/14 12:44:59 UTC
Store data in elasticsearch using apache camel
Hi I have a complex json string like
[{"id":1,"name":"test1"},{"id":2,"name":"test2"},...]
I convert this body into map but I can't index into elasticsearch due to
this error
Caused by: org.apache.camel.TypeConversionException: Error during type
conversion from type: java.lang.String to the required type:
org.elasticsearch.action.index.IndexRequest with value [{id=1, nom=test1},
{id=2, nom=test2... [Body clipped after 1000 chars, total length is 26866]
due java.lang.NullPointerException
How can I resolve this problem ?
Ps how I convert the body into map :
String body =exchange.getIn().getBody(String.class);
try {
TypeFactory typeFactory = mapper.getTypeFactory();
CollectionType collectionType =
typeFactory.constructCollectionType(
List.class, Object.class);
exchange.getIn().setBody(mapper.readValue(body, collectionType));
} catch (IOException e) {
e.printStackTrace();
}
--
View this message in context: http://camel.465427.n5.nabble.com/Store-data-in-elasticsearch-using-apache-camel-tp5799479.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Store data in elasticsearch using apache camel
Posted by nesrine <ne...@gmail.com>.
Thank you but the problem that the string json response is a response from
an rest api and since I have different responses from different rest "apis"
I don't think that I could have a specific custom converter could I ?
--
View this message in context: http://camel.465427.n5.nabble.com/Store-data-in-elasticsearch-using-apache-camel-tp5799479p5799483.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Store data in elasticsearch using apache camel
Posted by giannis_k <ik...@yahoo.gr>.
Hello,
you need to define a custom type converter to convert from String to the
type that you want. Check the documentation for type conversion here:
http://camel.apache.org/type-converter.html
--
View this message in context: http://camel.465427.n5.nabble.com/Store-data-in-elasticsearch-using-apache-camel-tp5799479p5799481.html
Sent from the Camel - Users mailing list archive at Nabble.com.