Re: SOLRJ Atomic updates of String field
I understood the query now. Atomic Update and Optimistic Concurrency are independent in Solr version 5. Not sure about version 4.2, if they are combined in this version a _version_ field is needed to pass in every update. The atomic/partial update will succeed if version in the request and indexed doc matches otherwise response will have HTTP error code 409. You can try by passing the _version_ of indexed doc during update. It's also good to add a unit test in Solr for partial update which currently I see missing. On Wed, Nov 12, 2014 at 1:00 PM, Ahmet Arslan iori...@yahoo.com.invalid wrote: Hi Bbarani, Partial update solrJ example can be found in : http://find.searchhub.org/document/5b1187abfcfad33f Ahmet On Tuesday, November 11, 2014 8:51 PM, bbarani bbar...@gmail.com wrote: I am using the below code to do partial update (in SOLR 4.2) partialUpdate = new HashMapString, Object(); partialUpdate.put(set,Object); doc.setField(description, partialUpdate); server.add(docs); server.commit(); I am seeing the below description value with {set =...}, Any idea why this is getting added? str name=description {set=The iPhone 6 Plus features a 5.5-inch retina HD display, the A8 chip for faster processing and longer battery life, the M8 motion coprocessor to track speed, distance and elevation, and with an 8MP iSight camera, you can record 1080p HD Video at 60 FPS!} /str -- View this message in context: http://lucene.472066.n3.nabble.com/SOLRJ-Atomic-updates-of-String-field-tp4168809.html Sent from the Solr - User mailing list archive at Nabble.com.
SOLRJ Atomic updates of String field
I am using the below code to do partial update (in SOLR 4.2) partialUpdate = new HashMapString, Object(); partialUpdate.put(set,Object); doc.setField(description, partialUpdate); server.add(docs); server.commit(); I am seeing the below description value with {set =...}, Any idea why this is getting added? str name=description {set=The iPhone 6 Plus features a 5.5-inch retina HD display, the A8 chip for faster processing and longer battery life, the M8 motion coprocessor to track speed, distance and elevation, and with an 8MP iSight camera, you can record 1080p HD Video at 60 FPS!} /str -- View this message in context: http://lucene.472066.n3.nabble.com/SOLRJ-Atomic-updates-of-String-field-tp4168809.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: SOLRJ Atomic updates of String field
Sorry didn't get what you are trying to achieve and the issue. On Wed, Nov 12, 2014 at 12:20 AM, bbarani bbar...@gmail.com wrote: I am using the below code to do partial update (in SOLR 4.2) partialUpdate = new HashMapString, Object(); partialUpdate.put(set,Object); doc.setField(description, partialUpdate); server.add(docs); server.commit(); I am seeing the below description value with {set =...}, Any idea why this is getting added? str name=description {set=The iPhone 6 Plus features a 5.5-inch retina HD display, the A8 chip for faster processing and longer battery life, the M8 motion coprocessor to track speed, distance and elevation, and with an 8MP iSight camera, you can record 1080p HD Video at 60 FPS!} /str -- View this message in context: http://lucene.472066.n3.nabble.com/SOLRJ-Atomic-updates-of-String-field-tp4168809.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: SOLRJ Atomic updates of String field
Hi Bbarani, Partial update solrJ example can be found in : http://find.searchhub.org/document/5b1187abfcfad33f Ahmet On Tuesday, November 11, 2014 8:51 PM, bbarani bbar...@gmail.com wrote: I am using the below code to do partial update (in SOLR 4.2) partialUpdate = new HashMapString, Object(); partialUpdate.put(set,Object); doc.setField(description, partialUpdate); server.add(docs); server.commit(); I am seeing the below description value with {set =...}, Any idea why this is getting added? str name=description {set=The iPhone 6 Plus features a 5.5-inch retina HD display, the A8 chip for faster processing and longer battery life, the M8 motion coprocessor to track speed, distance and elevation, and with an 8MP iSight camera, you can record 1080p HD Video at 60 FPS!} /str -- View this message in context: http://lucene.472066.n3.nabble.com/SOLRJ-Atomic-updates-of-String-field-tp4168809.html Sent from the Solr - User mailing list archive at Nabble.com.
SolrJ | Atomic Updates | How works exactly?
i have very big documents in the index. i want to update a multivalue field of a document, without loading the whole document. how can i do this? is there somewhere a good documentation? regards -- View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-Atomic-Updates-How-works-exactly-tp4032976.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: SolrJ | Atomic Updates | How works exactly?
Atomic updates work by storing (stored=true) all the fields (note, you don't have to set stored=true for the destinations of copyField). Anyway, when you use the atomic update syntax under the covers Solr reads all the stored fields out, re-assembles the document and re-indexes it. So your index may be significantly larger. Also note that in the 4.1 world, stored fields are automatically compressed so this may not be so much of a problem. And, there's been at least 1 or 2 fixes to this since 4.0 as I remember, so you might want to wait for 4.1 to experiment with (there's talk of cutting RC1 for Solr4.1 early next week) or use a nightly build. Best Erick On Sun, Jan 13, 2013 at 3:43 AM, uwe72 uwe.clem...@exxcellent.de wrote: i have very big documents in the index. i want to update a multivalue field of a document, without loading the whole document. how can i do this? is there somewhere a good documentation? regards -- View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-Atomic-Updates-How-works-exactly-tp4032976.html Sent from the Solr - User mailing list archive at Nabble.com.
AW: SolrJ | Atomic Updates | How works exactly?
Thanks erick, the main reason why i want to use atomic updates is, to increase updating existing kind of large documents. So if under to cover, everything is the same (loading the whole doc, updating, re-index the whole doc) it is not interesting for me anymore. What is the best the most performant way to update a large document? Any recommendations? THANKS! -Ursprüngliche Nachricht- Von: Erick Erickson [mailto:erickerick...@gmail.com] Gesendet: Sonntag, 13. Januar 2013 16.53 An: solr-user@lucene.apache.org Betreff: Re: SolrJ | Atomic Updates | How works exactly? Atomic updates work by storing (stored=true) all the fields (note, you don't have to set stored=true for the destinations of copyField). Anyway, when you use the atomic update syntax under the covers Solr reads all the stored fields out, re-assembles the document and re-indexes it. So your index may be significantly larger. Also note that in the 4.1 world, stored fields are automatically compressed so this may not be so much of a problem. And, there's been at least 1 or 2 fixes to this since 4.0 as I remember, so you might want to wait for 4.1 to experiment with (there's talk of cutting RC1 for Solr4.1 early next week) or use a nightly build. Best Erick On Sun, Jan 13, 2013 at 3:43 AM, uwe72 uwe.clem...@exxcellent.de wrote: i have very big documents in the index. i want to update a multivalue field of a document, without loading the whole document. how can i do this? is there somewhere a good documentation? regards -- View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-Atomic-Updates-How-works-exac tly-tp4032976.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: SolrJ | Atomic Updates | How works exactly?
On Sun, Jan 13, 2013 at 1:51 PM, Uwe Clement uwe.clem...@exxcellent.de wrote: What is the best the most performant way to update a large document? That *is* the best way to update a large document that we currently have. Although it re-indexes under the covers, it ensures that it's atomic, and it's faster because it does everything in a single request. -Yonik http://lucidworks.com
AW: SolrJ | Atomic Updates | How works exactly?
Thanks Yonik. Is this already working well on solr 4.0? or better to wait until solr 4.1?! -Ursprüngliche Nachricht- Von: ysee...@gmail.com [mailto:ysee...@gmail.com] Im Auftrag von Yonik Seeley Gesendet: Sonntag, 13. Januar 2013 20.24 An: solr-user@lucene.apache.org Betreff: Re: SolrJ | Atomic Updates | How works exactly? On Sun, Jan 13, 2013 at 1:51 PM, Uwe Clement uwe.clem...@exxcellent.de wrote: What is the best the most performant way to update a large document? That *is* the best way to update a large document that we currently have. Although it re-indexes under the covers, it ensures that it's atomic, and it's faster because it does everything in a single request. -Yonik http://lucidworks.com
Re: SolrJ | Atomic Updates | How works exactly?
This is present in 4.0. Not sure if there re ny improvements in 4.1. Upayavira On Sun, Jan 13, 2013, at 07:35 PM, Uwe Clement wrote: Thanks Yonik. Is this already working well on solr 4.0? or better to wait until solr 4.1?! -Ursprüngliche Nachricht- Von: ysee...@gmail.com [mailto:ysee...@gmail.com] Im Auftrag von Yonik Seeley Gesendet: Sonntag, 13. Januar 2013 20.24 An: solr-user@lucene.apache.org Betreff: Re: SolrJ | Atomic Updates | How works exactly? On Sun, Jan 13, 2013 at 1:51 PM, Uwe Clement uwe.clem...@exxcellent.de wrote: What is the best the most performant way to update a large document? That *is* the best way to update a large document that we currently have. Although it re-indexes under the covers, it ensures that it's atomic, and it's faster because it does everything in a single request. -Yonik http://lucidworks.com
Re: SolrJ | Atomic Updates | How works exactly?
There's several JIRA issues, but I several were duplicates of the same underlying issue: https://issues.apache.org/jira/issues/?jql=project%20%3D%20SOLR%20AND%20issuetype%20%3D%20Bug%20AND%20fixVersion%20%3D%20%224.1%22%20AND%20status%20%3D%20Resolved%20AND%20text%20~%20%22atomic%20update%22 Erik On Jan 13, 2013, at 19:49 , Upayavira wrote: This is present in 4.0. Not sure if there re ny improvements in 4.1. Upayavira On Sun, Jan 13, 2013, at 07:35 PM, Uwe Clement wrote: Thanks Yonik. Is this already working well on solr 4.0? or better to wait until solr 4.1?! -Ursprüngliche Nachricht- Von: ysee...@gmail.com [mailto:ysee...@gmail.com] Im Auftrag von Yonik Seeley Gesendet: Sonntag, 13. Januar 2013 20.24 An: solr-user@lucene.apache.org Betreff: Re: SolrJ | Atomic Updates | How works exactly? On Sun, Jan 13, 2013 at 1:51 PM, Uwe Clement uwe.clem...@exxcellent.de wrote: What is the best the most performant way to update a large document? That *is* the best way to update a large document that we currently have. Although it re-indexes under the covers, it ensures that it's atomic, and it's faster because it does everything in a single request. -Yonik http://lucidworks.com
SolrJ: atomic updates.
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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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
Re: SolrJ: atomic updates.
Thread update: When I use a simple: *Map operation = new HashMap();* Instead of: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. Is impossible to update atomically a multivalued field with a List of values in just one atomic update operation? 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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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
Re: SolrJ: atomic updates.
On Thu, Nov 15, 2012 at 11:51 AM, Luis Cappa Banda luisca...@gmail.comwrote: Thread update: When I use a simple: *Map operation = new HashMap();* Instead of: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. 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 ArrayListString 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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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
Re: SolrJ: atomic updates.
Hello, Sami. It will be the first issue that I open so, should I create it under Solr 4.0 version or in Solr 4.1.0 one? Thanks, - Luis Cappa. 2012/11/15 Sami Siren ssi...@gmail.com 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: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. 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 ArrayListString 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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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 -- - Luis Cappa
Re: SolrJ: atomic updates.
Ok, done: https://issues.apache.org/jira/browse/SOLR-4080 Regards, - Luis Cappa. 2012/11/15 Luis Cappa Banda luisca...@gmail.com Hello, Sami. It will be the first issue that I open so, should I create it under Solr 4.0 version or in Solr 4.1.0 one? Thanks, - Luis Cappa. 2012/11/15 Sami Siren ssi...@gmail.com 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: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. 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 ArrayListString 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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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 -- - Luis Cappa -- - Luis Cappa
Re: SolrJ: atomic updates.
Actually it seems that xml/binary request writers only behave differently when using array[] as the value. if I use ArrayList it also works with the xml format (4.1 branch). Still it's annoying that the two request writers behave differently so I guess it's worth adding the jira anyway. The Affects version should be 4.0. On Thu, Nov 15, 2012 at 1:42 PM, Luis Cappa Banda luisca...@gmail.comwrote: Hello, Sami. It will be the first issue that I open so, should I create it under Solr 4.0 version or in Solr 4.1.0 one? Thanks, - Luis Cappa. 2012/11/15 Sami Siren ssi...@gmail.com 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: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. 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 ArrayListString 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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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 -- - Luis Cappa
Re: SolrJ: atomic updates.
I´ll have a look to Solr source code and try to fix the bug. If I succeed I´ll update JIRA issue with it, :-) 2012/11/15 Sami Siren ssi...@gmail.com Actually it seems that xml/binary request writers only behave differently when using array[] as the value. if I use ArrayList it also works with the xml format (4.1 branch). Still it's annoying that the two request writers behave differently so I guess it's worth adding the jira anyway. The Affects version should be 4.0. On Thu, Nov 15, 2012 at 1:42 PM, Luis Cappa Banda luisca...@gmail.com wrote: Hello, Sami. It will be the first issue that I open so, should I create it under Solr 4.0 version or in Solr 4.1.0 one? Thanks, - Luis Cappa. 2012/11/15 Sami Siren ssi...@gmail.com 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: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. 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 ArrayListString 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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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 -- - Luis Cappa -- - Luis Cappa
Re: SolrJ: atomic updates.
Hi, Sami. Doing some tests I´ve used the same code as you and did a quick execution: *HttpSolrServer server = new HttpSolrServer( http://localhost:8080/solrserver/core1http://localhost:10080/newscover_es/items_es );* * * * try {* * * * HashMap editTags = new HashMap();* * editTags.put(set, new String[]{tag1,tag2,tag3});* * doc.addField(myField, editTags);* * server.add(doc);* * server.commit(true, true);* * * * } catch (SolrServerException e) {* * e.printStackTrace();* * } catch (IOException e) {* * e.printStackTrace();* * }* * * * * And the resultant doc is wrong: response lst name=responseHeader int name=status0/int int name=QTime1/int lst name=params str name=q*:*/str /lst /lst result name=response numFound=1 start=0 doc str name=i_id50a0f1f90cf226fb5677fe13/str arr name=myField *str[Ljava.lang.String;@7d5e90cb/str --- toString() from String[] array.* /arr long name=_version_1418710023780958208/long /doc /result /response So is definetely executing toString() method in both *HttpSolrServer *and * CloudServer*. Tips: - I´m using* Solrj 4.0.0 *artifact version in a *Maven *project. - The fields to be updated are *dynamicFields*. - I´m using Java jdk6. Alternatives: - I´m doing something wrong and I´m so stupid that I can´t see it, :-( - The way I update fields is not the correct one. - There is a general bug with atomic updates via SolrJ. Regards, - Luis Cappa. 2012/11/15 Luis Cappa Banda luisca...@gmail.com I´ll have a look to Solr source code and try to fix the bug. If I succeed I´ll update JIRA issue with it, :-) 2012/11/15 Sami Siren ssi...@gmail.com Actually it seems that xml/binary request writers only behave differently when using array[] as the value. if I use ArrayList it also works with the xml format (4.1 branch). Still it's annoying that the two request writers behave differently so I guess it's worth adding the jira anyway. The Affects version should be 4.0. On Thu, Nov 15, 2012 at 1:42 PM, Luis Cappa Banda luisca...@gmail.com wrote: Hello, Sami. It will be the first issue that I open so, should I create it under Solr 4.0 version or in Solr 4.1.0 one? Thanks, - Luis Cappa. 2012/11/15 Sami Siren ssi...@gmail.com 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: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. 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 ArrayListString 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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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
Re: SolrJ: atomic updates.
Try setting Request writer to binary like this: server.setParser(new BinaryResponseParser()); server.setRequestWriter(new BinaryRequestWriter()); Or then instead of string array use ArrayListString() that contains your strings as the value for the map On Thu, Nov 15, 2012 at 3:58 PM, Luis Cappa Banda luisca...@gmail.comwrote: Hi, Sami. Doing some tests I´ve used the same code as you and did a quick execution: *HttpSolrServer server = new HttpSolrServer( http://localhost:8080/solrserver/core1 http://localhost:10080/newscover_es/items_es );* * * * try {* * * * HashMap editTags = new HashMap();* * editTags.put(set, new String[]{tag1,tag2,tag3});* * doc.addField(myField, editTags);* * server.add(doc);* * server.commit(true, true);* * * * } catch (SolrServerException e) {* * e.printStackTrace();* * } catch (IOException e) {* * e.printStackTrace();* * }* * * * * And the resultant doc is wrong: response lst name=responseHeader int name=status0/int int name=QTime1/int lst name=params str name=q*:*/str /lst /lst result name=response numFound=1 start=0 doc str name=i_id50a0f1f90cf226fb5677fe13/str arr name=myField *str[Ljava.lang.String;@7d5e90cb/str --- toString() from String[] array.* /arr long name=_version_1418710023780958208/long /doc /result /response So is definetely executing toString() method in both *HttpSolrServer *and * CloudServer*. Tips: - I´m using* Solrj 4.0.0 *artifact version in a *Maven *project. - The fields to be updated are *dynamicFields*. - I´m using Java jdk6. Alternatives: - I´m doing something wrong and I´m so stupid that I can´t see it, :-( - The way I update fields is not the correct one. - There is a general bug with atomic updates via SolrJ. Regards, - Luis Cappa. 2012/11/15 Luis Cappa Banda luisca...@gmail.com I´ll have a look to Solr source code and try to fix the bug. If I succeed I´ll update JIRA issue with it, :-) 2012/11/15 Sami Siren ssi...@gmail.com Actually it seems that xml/binary request writers only behave differently when using array[] as the value. if I use ArrayList it also works with the xml format (4.1 branch). Still it's annoying that the two request writers behave differently so I guess it's worth adding the jira anyway. The Affects version should be 4.0. On Thu, Nov 15, 2012 at 1:42 PM, Luis Cappa Banda luisca...@gmail.com wrote: Hello, Sami. It will be the first issue that I open so, should I create it under Solr 4.0 version or in Solr 4.1.0 one? Thanks, - Luis Cappa. 2012/11/15 Sami Siren ssi...@gmail.com 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: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. 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 ArrayListString 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);* * * *MapString, ListString operation = new HashMapString, ListString();* *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
Re: SolrJ: atomic updates.
Uhm, after setting both Response and Request Writers it worked OK with * HttpSolrServer*. I´ve tried to find a way to set BinaryResponseParser and BinaryRequestWriter with *CloudServer *(or even via *LbHttpSolrServer*) but I found nothing. Suggestions? :-/ - Luis Cappa. 2012/11/15 Sami Siren ssi...@gmail.com Try setting Request writer to binary like this: server.setParser(new BinaryResponseParser()); server.setRequestWriter(new BinaryRequestWriter()); Or then instead of string array use ArrayListString() that contains your strings as the value for the map On Thu, Nov 15, 2012 at 3:58 PM, Luis Cappa Banda luisca...@gmail.com wrote: Hi, Sami. Doing some tests I´ve used the same code as you and did a quick execution: *HttpSolrServer server = new HttpSolrServer( http://localhost:8080/solrserver/core1 http://localhost:10080/newscover_es/items_es );* * * * try {* * * * HashMap editTags = new HashMap();* * editTags.put(set, new String[]{tag1,tag2,tag3});* * doc.addField(myField, editTags);* * server.add(doc);* * server.commit(true, true);* * * * } catch (SolrServerException e) {* * e.printStackTrace();* * } catch (IOException e) {* * e.printStackTrace();* * }* * * * * And the resultant doc is wrong: response lst name=responseHeader int name=status0/int int name=QTime1/int lst name=params str name=q*:*/str /lst /lst result name=response numFound=1 start=0 doc str name=i_id50a0f1f90cf226fb5677fe13/str arr name=myField *str[Ljava.lang.String;@7d5e90cb/str --- toString() from String[] array.* /arr long name=_version_1418710023780958208/long /doc /result /response So is definetely executing toString() method in both *HttpSolrServer *and * CloudServer*. Tips: - I´m using* Solrj 4.0.0 *artifact version in a *Maven *project. - The fields to be updated are *dynamicFields*. - I´m using Java jdk6. Alternatives: - I´m doing something wrong and I´m so stupid that I can´t see it, :-( - The way I update fields is not the correct one. - There is a general bug with atomic updates via SolrJ. Regards, - Luis Cappa. 2012/11/15 Luis Cappa Banda luisca...@gmail.com I´ll have a look to Solr source code and try to fix the bug. If I succeed I´ll update JIRA issue with it, :-) 2012/11/15 Sami Siren ssi...@gmail.com Actually it seems that xml/binary request writers only behave differently when using array[] as the value. if I use ArrayList it also works with the xml format (4.1 branch). Still it's annoying that the two request writers behave differently so I guess it's worth adding the jira anyway. The Affects version should be 4.0. On Thu, Nov 15, 2012 at 1:42 PM, Luis Cappa Banda luisca...@gmail.com wrote: Hello, Sami. It will be the first issue that I open so, should I create it under Solr 4.0 version or in Solr 4.1.0 one? Thanks, - Luis Cappa. 2012/11/15 Sami Siren ssi...@gmail.com 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: *MapString, ListString operation = new HashMapString, ListString();* The result looks better, but it´s still wrong: fieldName: [ [Value1, Value2] ], However, ListString value is received as a simple String [Value1, Value2]. In other words, SolrJ is internally executing a toString() operation to the ListSring. 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 ArrayListString 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