You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jack Park <ja...@topicquests.org> on 2013/02/21 05:16:35 UTC

Document update question

>From what I can read about partial updates, it will only work for
singleton fields where you can set them to something else, or
multi-valued fields where you can add something. I am testing on 4.1

I ran some tests to prove to me that you cannot do anything else to a
multi-valued field, like remove a value and do a partial update on the
whole list. It flattens the result to a comma delimited String when I
remove a value, from
       "details": [
          "here & there",
          "Hello there",
          "Oh Fudge"
        ],
to this
   "details": [
          "[here & there, Oh Fudge]"
        ],

Does this meant that I must remove the entire document and re-index it?

Many thanks in advance
Jack

Re: Document update question

Posted by Jack Park <ja...@topicquests.org>.
I uncommented out the line which sets server to an XMLResponse parser,
and used the following code in a tiny test:

		String sourceNodeLocator = node.getLocator();
		Map<String,Object> updateMap = new HashMap<String,Object>();
		Map<String,Object> newMap = new HashMap<String,Object>();
		Map<String,Object> myMap = node.getProperties();
		List<String>values = (List<String>) myMap.get(key);
		String what = "set";
		values.add(newValue);
		updateMap.put(ITopicQuestsOntology.LOCATOR_PROPERTY, sourceNodeLocator);
		newMap.put(what,values);
		updateMap.put(key, newMap);
		IResult result = solr.partialUpdateData(updateMap);;

The printstring fragment from that test look like this:

<node locator="MySecondNode1361728848603">
  <property key="details" >
    <value><![CDATA[here & there]]></value>
    <value><![CDATA[Oh Fudge]]></value>
  </property>

and fetching in JSON from the admin query console looks like this:
        "locator": "MySecondNode1361728848603",
        "details": [
          "here & there",
          "Oh Fudge"
        ],

It appears that using the XMLResponseParser and getting the query
string right works!

Many thanks for all the comments.

Cheers
Jack

On Thu, Feb 21, 2013 at 5:45 PM, Shawn Heisey <so...@elyograg.org> wrote:
> On 2/21/2013 10:00 AM, Jack Park wrote:
>>
>> Interesting you should say that.  Here is my solrj code:
>>
>>         public Solr3Client(String solrURL) throws Exception {
>>                 server = new HttpSolrServer(solrURL);
>>         //      server.setParser(new XMLResponseParser());
>>         }
>>
>> I cannot recall why I commented out the setParser line; something
>> about someone saying in another thread it's not important. I suppose I
>> should revisit my unit tests with that line uncommented. Or, did I
>> miss something?
>>
>> The JSON results I painted earlier were from reading the document
>> online in the admin query panel.
>
>
> Jack,
>
> SolrJ defaults to the javabin response parser, which offers maximum
> efficiency in the communication.  Between version 1.4.1 and 3.1.0, the
> javabin version changed and became incompatible with the old one.
>
> The XML parser is a little bit less efficient than javabin, but is the only
> way to get Solr/SolrJ to talk when one side is using a different javabin
> version than the other side.  If you are not mixing 1.x with later versions,
> you do not need to worry about changing the response parser.
>
> Thanks,
> Shawn
>

Re: Document update question

Posted by Shawn Heisey <so...@elyograg.org>.
On 2/21/2013 10:00 AM, Jack Park wrote:
> Interesting you should say that.  Here is my solrj code:
>
> 	public Solr3Client(String solrURL) throws Exception {
> 		server = new HttpSolrServer(solrURL);
> 	//	server.setParser(new XMLResponseParser());
> 	}
>
> I cannot recall why I commented out the setParser line; something
> about someone saying in another thread it's not important. I suppose I
> should revisit my unit tests with that line uncommented. Or, did I
> miss something?
>
> The JSON results I painted earlier were from reading the document
> online in the admin query panel.

Jack,

SolrJ defaults to the javabin response parser, which offers maximum 
efficiency in the communication.  Between version 1.4.1 and 3.1.0, the 
javabin version changed and became incompatible with the old one.

The XML parser is a little bit less efficient than javabin, but is the 
only way to get Solr/SolrJ to talk when one side is using a different 
javabin version than the other side.  If you are not mixing 1.x with 
later versions, you do not need to worry about changing the response parser.

Thanks,
Shawn


Re: Document update question

Posted by Jack Park <ja...@topicquests.org>.
Interesting you should say that.  Here is my solrj code:

	public Solr3Client(String solrURL) throws Exception {
		server = new HttpSolrServer(solrURL);
	//	server.setParser(new XMLResponseParser());
	}

I cannot recall why I commented out the setParser line; something
about someone saying in another thread it's not important. I suppose I
should revisit my unit tests with that line uncommented. Or, did I
miss something?

The JSON results I painted earlier were from reading the document
online in the admin query panel.

Many thanks
Jack

On Thu, Feb 21, 2013 at 8:52 AM, Timothy Potter <th...@gmail.com> wrote:
> Weird - the only difference I see is that we us XML vs. JSON, but
> otherwise, doing the following works for us:
>
> <field update="set" name="someMultiValuedField">VALU1</field>
> <field update="set" name="someMultiValuedField">VALU2</field>
>
> Result would be:
>
> <arr name="someMultiValuedField">
>   <str>VALU1</str>
>   <str>VALU2</str>
> </arr>
>
>
> On Thu, Feb 21, 2013 at 9:44 AM, Jack Park <ja...@topicquests.org> wrote:
>> I am using 4.1. I was not aware of that link. In the absence of being
>> able to do partial updates to multi-valued fields, I just punted to
>> delete and reindex. I'd like to see otherwise.
>>
>> Many thanks
>> Jack
>>
>> On Thu, Feb 21, 2013 at 8:13 AM, Timothy Potter <th...@gmail.com> wrote:
>>> Hi Jack,
>>>
>>> There was a bug for this fixed for 4.1 - which version are you on? I
>>> remember this b/c I was on 4.0 and had to upgrade for this exact
>>> reason.
>>>
>>> https://issues.apache.org/jira/browse/SOLR-4134
>>>
>>> Tim
>>>
>>> On Wed, Feb 20, 2013 at 9:16 PM, Jack Park <ja...@topicquests.org> wrote:
>>>> From what I can read about partial updates, it will only work for
>>>> singleton fields where you can set them to something else, or
>>>> multi-valued fields where you can add something. I am testing on 4.1
>>>>
>>>> I ran some tests to prove to me that you cannot do anything else to a
>>>> multi-valued field, like remove a value and do a partial update on the
>>>> whole list. It flattens the result to a comma delimited String when I
>>>> remove a value, from
>>>>        "details": [
>>>>           "here & there",
>>>>           "Hello there",
>>>>           "Oh Fudge"
>>>>         ],
>>>> to this
>>>>    "details": [
>>>>           "[here & there, Oh Fudge]"
>>>>         ],
>>>>
>>>> Does this meant that I must remove the entire document and re-index it?
>>>>
>>>> Many thanks in advance
>>>> Jack

Re: Document update question

Posted by Timothy Potter <th...@gmail.com>.
Weird - the only difference I see is that we us XML vs. JSON, but
otherwise, doing the following works for us:

<field update="set" name="someMultiValuedField">VALU1</field>
<field update="set" name="someMultiValuedField">VALU2</field>

Result would be:

<arr name="someMultiValuedField">
  <str>VALU1</str>
  <str>VALU2</str>
</arr>


On Thu, Feb 21, 2013 at 9:44 AM, Jack Park <ja...@topicquests.org> wrote:
> I am using 4.1. I was not aware of that link. In the absence of being
> able to do partial updates to multi-valued fields, I just punted to
> delete and reindex. I'd like to see otherwise.
>
> Many thanks
> Jack
>
> On Thu, Feb 21, 2013 at 8:13 AM, Timothy Potter <th...@gmail.com> wrote:
>> Hi Jack,
>>
>> There was a bug for this fixed for 4.1 - which version are you on? I
>> remember this b/c I was on 4.0 and had to upgrade for this exact
>> reason.
>>
>> https://issues.apache.org/jira/browse/SOLR-4134
>>
>> Tim
>>
>> On Wed, Feb 20, 2013 at 9:16 PM, Jack Park <ja...@topicquests.org> wrote:
>>> From what I can read about partial updates, it will only work for
>>> singleton fields where you can set them to something else, or
>>> multi-valued fields where you can add something. I am testing on 4.1
>>>
>>> I ran some tests to prove to me that you cannot do anything else to a
>>> multi-valued field, like remove a value and do a partial update on the
>>> whole list. It flattens the result to a comma delimited String when I
>>> remove a value, from
>>>        "details": [
>>>           "here & there",
>>>           "Hello there",
>>>           "Oh Fudge"
>>>         ],
>>> to this
>>>    "details": [
>>>           "[here & there, Oh Fudge]"
>>>         ],
>>>
>>> Does this meant that I must remove the entire document and re-index it?
>>>
>>> Many thanks in advance
>>> Jack

Re: Document update question

Posted by Jack Park <ja...@topicquests.org>.
I am using 4.1. I was not aware of that link. In the absence of being
able to do partial updates to multi-valued fields, I just punted to
delete and reindex. I'd like to see otherwise.

Many thanks
Jack

On Thu, Feb 21, 2013 at 8:13 AM, Timothy Potter <th...@gmail.com> wrote:
> Hi Jack,
>
> There was a bug for this fixed for 4.1 - which version are you on? I
> remember this b/c I was on 4.0 and had to upgrade for this exact
> reason.
>
> https://issues.apache.org/jira/browse/SOLR-4134
>
> Tim
>
> On Wed, Feb 20, 2013 at 9:16 PM, Jack Park <ja...@topicquests.org> wrote:
>> From what I can read about partial updates, it will only work for
>> singleton fields where you can set them to something else, or
>> multi-valued fields where you can add something. I am testing on 4.1
>>
>> I ran some tests to prove to me that you cannot do anything else to a
>> multi-valued field, like remove a value and do a partial update on the
>> whole list. It flattens the result to a comma delimited String when I
>> remove a value, from
>>        "details": [
>>           "here & there",
>>           "Hello there",
>>           "Oh Fudge"
>>         ],
>> to this
>>    "details": [
>>           "[here & there, Oh Fudge]"
>>         ],
>>
>> Does this meant that I must remove the entire document and re-index it?
>>
>> Many thanks in advance
>> Jack

Re: Document update question

Posted by Timothy Potter <th...@gmail.com>.
Hi Jack,

There was a bug for this fixed for 4.1 - which version are you on? I
remember this b/c I was on 4.0 and had to upgrade for this exact
reason.

https://issues.apache.org/jira/browse/SOLR-4134

Tim

On Wed, Feb 20, 2013 at 9:16 PM, Jack Park <ja...@topicquests.org> wrote:
> From what I can read about partial updates, it will only work for
> singleton fields where you can set them to something else, or
> multi-valued fields where you can add something. I am testing on 4.1
>
> I ran some tests to prove to me that you cannot do anything else to a
> multi-valued field, like remove a value and do a partial update on the
> whole list. It flattens the result to a comma delimited String when I
> remove a value, from
>        "details": [
>           "here & there",
>           "Hello there",
>           "Oh Fudge"
>         ],
> to this
>    "details": [
>           "[here & there, Oh Fudge]"
>         ],
>
> Does this meant that I must remove the entire document and re-index it?
>
> Many thanks in advance
> Jack