On Thu, Nov 15, 2012 at 11:51 AM, Luis Cappa Banda <luisca...@gmail.com>wrote:
> Thread update: > > When I use a simple: > > *Map operation = new HashMap();* > > > Instead of: > > *Map<String, List<String>> operation = new HashMap<String, > List<String>>();* > > > The result looks better, but it´s still wrong: > > fieldName: [ > "[Value1, Value2]" > ], > > > However, List<String> value is received as a simple String "[Value1, > Value2]". In other words, SolrJ is internally executing a toString() > operation to the List<Sring>. Is impossible to update atomically a > multivalued field with a List of values in just one atomic update > operation? > Seems to be working fine here with HttpSolrServer / BinaryRequestWriter; HashMap editTags = new HashMap(); editTags.put("set", new String[]{"tag1","tag2","tag3"}); doc = new SolrInputDocument(); doc.addField("id", "unique"); doc.addField("tags_ss", editTags); server.add(doc); server.commit(true, true); resp = server.query(q); System.out.println(resp.getResults().get(0).getFirstValue("tags_ss")); prints "tag1" ArrayList<String> as a value works the same way as String[]. When using xml (RequestWriter) I can see the problem that you are describing, can you add a jira for that? -- Sami SIren > > Regards, > > > - Luis Cappa. > > 2012/11/15 Luis Cappa Banda <luisca...@gmail.com> > > > Hello everyone, > > > > I´ve tested atomic updates via Ajax calls and now I´m starting with > atomic > > updates via SolrJ... but the way I´m proceeding doesn´t seem to work > well. > > Here is the snippet: > > > > *SolrInputDocument do = ne SolrInputDocument();* > > *doc.addField("id", "myId");* > > * > > * > > *Map<String, List<String>> operation = new HashMap<String, > > List<String>>();* > > *operation.put("set", [[a list of String elements]]); // I want a set > > operation to override field values.* > > *doc.addField("fieldName", operation);* > > * > > * > > *cloudSolrServer.add(doc); // Atomic update operation.* > > > > > > And after updating the resultant doc is as follows: > > > > *doc: {* > > * > > * > > *...* > > * > > * > > *fieldName: [ "{set=values}"* > > *],* > > * > > * > > *...* > > > > * > > * > > > > *}* > > > > In other words, the map which includes the "set" operation and the field > > values is String formatted and that String is used to update the field, > :-/ > > > > What is the correct way to update just one or more fields with SolrJ? > > > > > > Regards, > > > > -- > > > > - Luis Cappa > > > > > > > -- > > - Luis Cappa >