How do I use updateRequestBuilder.addScriptParam to add List/Arrays.
I want to replace "ctx._source.communities" with the list of maps called
"new_communities" but it always ends up as an empty array.
List<Map<String,Object>> communityMapList = new
ArrayList<Map<String,Object>>();
for(CommunityRelationship community :
communitiesByTwitterUser.get(userId)){
Map<String,Object> communityMap = new
HashMap<String,Object>();
communityMap.put("communityId", community.getCommunityId());
communityMap.put("communityName",
community.getCommunityName());
communityMapList.add(communityMap);
}
UpdateRequestBuilder updateRequestBuilder = client
.prepareUpdate(SearchFields.INDEX, SearchFields.USER_TYPE, userId)
.addScriptParam("new_communities", communityMapList)
.setConsistencyLevel(WriteConsistencyLevel.ALL)
.setRetryOnConflict(10)
.setScript("ctx._source.communities = new_communities");
I've figured out how to pass in a single community append but I'd really
like to pass in a list of communities.
This seems a simple thing to do using json (Just write out the string
[{"communityId":32,"communityName":"lukes_community"},[{"communityId":33,"communityName":"bills_community"}]
but I can't see how to pass this into the java api.
Any ideas?
Luke
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e48362ad-e7d2-48df-ae3c-02c0ad867b3c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.