Started using ElasticSearch on a new (to me) project and came across a
small issue while indexing sets.
Set set = ...
builder.field("fieldName", set);
The code will call the overloaded method XContentBuilder#field(String
name, Object value), since there is no method for the more restrictive
type Set. There is an overloaded method for
XContentBuilder#field(String name, List value), so the solution is to
simply create a list out of the set. However, looking at the latter
method, there should be no reason why the type should not be
Collection and not just List.
The aim is not to create a full object to json mapping in elasticsearch,
use jackson for that.
On Wed, Nov 30, 2011 at 2:10 AM, Ivan Brusic ivan@brusic.com wrote:
Started using Elasticsearch on a new (to me) project and came across a
small issue while indexing sets.
Set set = ...
builder.field("fieldName", set);
The code will call the overloaded method XContentBuilder#field(String
name, Object value), since there is no method for the more restrictive
type Set. There is an overloaded method for
XContentBuilder#field(String name, List value), so the solution is to
simply create a list out of the set. However, looking at the latter
method, there should be no reason why the type should not be
Collection and not just List.
Replace List with Collection and you should now be able to index items
such as Sets and even Vectors. Currently, a Set uses the Object level
overloaded method:
Since the if-elsif statements does not find set, it simply gets
converted with toString, but the List method would work perfectly.
The issue is very minor. The workaround is simple, but it would be
nice to have Collection level support and not just List.
Cheers,
Ivan
On Wed, Nov 30, 2011 at 3:09 AM, Shay Banon kimchy@gmail.com wrote:
The aim is not to create a full object to json mapping in elasticsearch, use
jackson for that.
On Wed, Nov 30, 2011 at 2:10 AM, Ivan Brusic ivan@brusic.com wrote:
Started using Elasticsearch on a new (to me) project and came across a
small issue while indexing sets.
Set set = ...
builder.field("fieldName", set);
The code will call the overloaded method XContentBuilder#field(String
name, Object value), since there is no method for the more restrictive
type Set. There is an overloaded method for
XContentBuilder#field(String name, List value), so the solution is to
simply create a list out of the set. However, looking at the latter
method, there should be no reason why the type should not be
Collection and not just List.
Replace List with Collection and you should now be able to index items
such as Sets and even Vectors. Currently, a Set uses the Object level
overloaded method:
Since the if-elsif statements does not find set, it simply gets
converted with toString, but the List method would work perfectly.
The issue is very minor. The workaround is simple, but it would be
nice to have Collection level support and not just List.
Cheers,
Ivan
On Wed, Nov 30, 2011 at 3:09 AM, Shay Banon kimchy@gmail.com wrote:
The aim is not to create a full object to json mapping in elasticsearch,
use
jackson for that.
On Wed, Nov 30, 2011 at 2:10 AM, Ivan Brusic ivan@brusic.com wrote:
Started using Elasticsearch on a new (to me) project and came across a
small issue while indexing sets.
Set set = ...
builder.field("fieldName", set);
The code will call the overloaded method XContentBuilder#field(String
name, Object value), since there is no method for the more restrictive
type Set. There is an overloaded method for
XContentBuilder#field(String name, List value), so the solution is to
simply create a list out of the set. However, looking at the latter
method, there should be no reason why the type should not be
Collection and not just List.
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.