This uses...
IndexResponse response = client.prepareIndex("typesindex", "type")
.setSource(json)
.execute()
.actionGet();
And works absolutely fine. However, if I want to add to the types list
using newobject =
{"label":"key2","value":"test2"}
and the script
ctx._source.types += newobject
Then I get the following error...
object mapping [types] trying to serialize a value with no field
associated with it, current value [{"label":"key2","value":"test2"}]
My code worked absolutely fine when it was just an array of strings as
opposed to objects.
This uses...
IndexResponse response = client.prepareIndex("typesindex", "type")
.setSource(json)
.execute()
.actionGet();
And works absolutely fine. However, if I want to add to the types list
using newobject =
{"label":"key2","value":"test2"}
and the script
ctx._source.types += newobject
Then I get the following error...
object mapping [types] trying to serialize a value with no field
associated with it, current value [{"label":"key2","value":"test2"}]
My code worked absolutely fine when it was just an array of strings as
opposed to objects.
Thanks for the quick response, but that is exactly what I am doing. It
works for me from the command line, just not from Java.
The following code does not work, but works fine as per your example from
command line.
//json built by jsonBuilder() and equals {"label":"key3","value":"test3"}
Throws the exception:
org.elasticsearch.index.mapper.MapperParsingException: object mapping
[types] trying to serialize a value with no field associated with it,
current value [{"label":"key3","value":"test3"}]
at
org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:583)
On Tuesday, March 26, 2013 3:27:20 AM UTC+4, Igor Motov wrote:
This uses...
IndexResponse response = client.prepareIndex("typesindex", "type")
.setSource(json)
.execute()
.actionGet();
And works absolutely fine. However, if I want to add to the types list
using newobject =
{"label":"key2","value":"test2"}
and the script
ctx._source.types += newobject
Then I get the following error...
object mapping [types] trying to serialize a value with no field
associated with it, current value [{"label":"key2","value":"test2"}]
My code worked absolutely fine when it was just an array of strings as
opposed to objects.
Ok solved it, the problem occurs when you use the Java
.addScriptParam(name, value).
To fix, simply craft the script yourself rather than using parameters.
(Only an issue in Java API, Curl works fine).
.setScript("ctx._source."+FIELD_NAME+" += "+json)
On Monday, March 25, 2013 1:21:12 PM UTC+4, JayTee wrote:
Hello,
I have some code in Java that adds a new document as follows...
This uses...
IndexResponse response = client.prepareIndex("typesindex", "type")
.setSource(json)
.execute()
.actionGet();
And works absolutely fine. However, if I want to add to the types list
using newobject =
{"label":"key2","value":"test2"}
and the script
ctx._source.types += newobject
Then I get the following error...
object mapping [types] trying to serialize a value with no field
associated with it, current value [{"label":"key2","value":"test2"}]
My code worked absolutely fine when it was just an array of strings as
opposed to objects.
On Tuesday, March 26, 2013 3:26:48 AM UTC-4, JayTee wrote:
Ok solved it, the problem occurs when you use the Java
.addScriptParam(name, value).
To fix, simply craft the script yourself rather than using parameters.
(Only an issue in Java API, Curl works fine).
.setScript("ctx._source."+FIELD_NAME+" += "+json)
On Monday, March 25, 2013 1:21:12 PM UTC+4, JayTee wrote:
Hello,
I have some code in Java that adds a new document as follows...
This uses...
IndexResponse response = client.prepareIndex("typesindex", "type")
.setSource(json)
.execute()
.actionGet();
And works absolutely fine. However, if I want to add to the types list
using newobject =
{"label":"key2","value":"test2"}
and the script
ctx._source.types += newobject
Then I get the following error...
object mapping [types] trying to serialize a value with no field
associated with it, current value [{"label":"key2","value":"test2"}]
My code worked absolutely fine when it was just an array of strings as
opposed to objects.
On Tuesday, March 26, 2013 3:26:48 AM UTC-4, JayTee wrote:
Ok solved it, the problem occurs when you use the Java
.addScriptParam(name, value).
To fix, simply craft the script yourself rather than using parameters.
(Only an issue in Java API, Curl works fine).
.setScript("ctx._source."+FIELD_NAME+" += "+json)
On Monday, March 25, 2013 1:21:12 PM UTC+4, JayTee wrote:
Hello,
I have some code in Java that adds a new document as follows...
This uses...
IndexResponse response = client.prepareIndex("typesindex", "type")
.setSource(json)
.execute()
.actionGet();
And works absolutely fine. However, if I want to add to the types list
using newobject =
{"label":"key2","value":"test2"}
and the script
ctx._source.types += newobject
Then I get the following error...
object mapping [types] trying to serialize a value with no field
associated with it, current value [{"label":"key2","value":"test2"}]
My code worked absolutely fine when it was just an array of strings as
opposed to objects.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.