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 Robert Krüger <kr...@lesspain.de> on 2013/06/05 16:37:06 UTC

copyField generates "multiple values encountered for non multiValued field"

I have the exact same problem as the guy here:

http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201105.mbox/%3C3A2B3E42FCAA4BF496AE625426C5C6E4@Wurstsemmel%3E

AFAICS he did not get an answer. Is this a known issue? What can I do
other than doing what copyField should do in my application?

I am using solr 4.0.0.

Thanks,

Robert

Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
I think the suggestion I have seen is that copyField should be
index-only and - therefore - will not be returned. It is primarily
there to make searching easier by aggregating fields or to provide
alternative analyzer pipeline.

Can you make your copyField destination not stored?

Regards,
   Alex.
Personal blog: http://blog.outerthoughts.com/
LinkedIn: http://www.linkedin.com/in/alexandrerafalovitch
- Time is the quality of nature that keeps events from happening all
at once. Lately, it doesn't seem to be working.  (Anonymous  - via GTD
book)


On Wed, Jun 5, 2013 at 10:37 AM, Robert Krüger <kr...@lesspain.de> wrote:
> I have the exact same problem as the guy here:
>
> http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201105.mbox/%3C3A2B3E42FCAA4BF496AE625426C5C6E4@Wurstsemmel%3E
>
> AFAICS he did not get an answer. Is this a known issue? What can I do
> other than doing what copyField should do in my application?
>
> I am using solr 4.0.0.
>
> Thanks,
>
> Robert

Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Jack Krupansky <ja...@basetechnology.com>.
1. Try a simple curl command to add the document.

2. Check to see if maybe there is a duplicate copyField directive in your 
schema. How many copyField directives do you have?

At least we know that it is exactly the same value duplicated and not some 
other value.

-- Jack Krupansky

-----Original Message----- 
From: Robert Krüger
Sent: Thursday, June 06, 2013 7:15 AM
To: solr-user@lucene.apache.org
Subject: Re: copyField generates "multiple values encountered for non 
multiValued field"

On Wed, Jun 5, 2013 at 9:12 PM, Jack Krupansky <ja...@basetechnology.com> 
wrote:
> Look in the Solr log - the error message should tell you what the multiple
> values are. For example,
>
> 95484 [qtp2998209-11] ERROR org.apache.solr.core.SolrCore  –
> org.apache.solr.common.SolrException: ERROR: [doc=doc-1] multiple values
> encountered for non multiValued field content_s: [def, abc]
>
> One of the values should be the value of the field that is the source of 
> the
> copyField. Maybe the other value will give you a clue as to where it came
> from.
>
> Check your SolrJ code - maybe you actually do try to initialize a value in
> the field that is the copyField target.

I see the values in the stack trace:

org.apache.solr.common.SolrException: ERROR:
[doc=8f60d040-3462-4b28-998f-fd05a64f1cd8:/] multiple values
encountered for non multiValued field name2: [rename, rename]

It is just twice the value of source-field and I am not referencing
that field in my java code. 


Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Robert Krüger <kr...@lesspain.de>.
On Wed, Jun 5, 2013 at 9:12 PM, Jack Krupansky <ja...@basetechnology.com> wrote:
> Look in the Solr log - the error message should tell you what the multiple
> values are. For example,
>
> 95484 [qtp2998209-11] ERROR org.apache.solr.core.SolrCore  –
> org.apache.solr.common.SolrException: ERROR: [doc=doc-1] multiple values
> encountered for non multiValued field content_s: [def, abc]
>
> One of the values should be the value of the field that is the source of the
> copyField. Maybe the other value will give you a clue as to where it came
> from.
>
> Check your SolrJ code - maybe you actually do try to initialize a value in
> the field that is the copyField target.

I see the values in the stack trace:

org.apache.solr.common.SolrException: ERROR:
[doc=8f60d040-3462-4b28-998f-fd05a64f1cd8:/] multiple values
encountered for non multiValued field name2: [rename, rename]

It is just twice the value of source-field and I am not referencing
that field in my java code.

Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Jack Krupansky <ja...@basetechnology.com>.
Look in the Solr log - the error message should tell you what the multiple 
values are. For example,

95484 [qtp2998209-11] ERROR org.apache.solr.core.SolrCore  – 
org.apache.solr.common.SolrException: ERROR: [doc=doc-1] multiple values 
encountered for non multiValued field content_s: [def, abc]

One of the values should be the value of the field that is the source of the 
copyField. Maybe the other value will give you a clue as to where it came 
from.

Check your SolrJ code - maybe you actually do try to initialize a value in 
the field that is the copyField target.

-- Jack Krupansky

-----Original Message----- 
From: Robert Krüger
Sent: Wednesday, June 05, 2013 1:17 PM
To: solr-user@lucene.apache.org
Subject: Re: copyField generates "multiple values encountered for non 
multiValued field"

OK, I have two fields defined as follows:

  <field name="name"   type="string"   indexed="true"  stored="true"
multiValued="false" />
  <field name="name2"   type="string_ci"   indexed="true"
stored="true"  multiValued="false" />

and this copyField directive

<copyField source="name" dest="name2"/>

I updated the Index using SolrJ and got the exact same error message
that is in the subject. However, while waiting for feedback I built a
workaround at the application level and now reconstructing the
original state, to be able to answer you, I have different behaviour.
What happens now is that the field "name2" is populated with multiple
values although it is not defined as multiValued (see above).

Although this is strange, it is consistent with the earlier problem in
that copyField does not seem to overwrite the existing field values. I
may be using it incorrectly (it's the first time I am using copyField)
but the docs in the wiki did not say anything about an overwrite
option.

Cheers,

Robert


On Wed, Jun 5, 2013 at 5:16 PM, Jack Krupansky <ja...@basetechnology.com> 
wrote:
> Try describing your own symptom in your own words - because his issue
> related to Solr 1.4. I mean, where exactly are you setting
> "allowDuplicates=false"?? And why do you think it has anything to do with
> adding documents to Solr? Solr 1.4 did not have atomic update, so sending
> the exact same document twice would not result in a change in the index
> (unless you had a date field with a value of "NOW".) Copy field only uses
> values from the current document.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Robert Krüger
> Sent: Wednesday, June 05, 2013 10:37 AM
> To: solr-user@lucene.apache.org
> Subject: copyField generates "multiple values encountered for non
> multiValued field"
>
>
> I have the exact same problem as the guy here:
>
> http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201105.mbox/%3C3A2B3E42FCAA4BF496AE625426C5C6E4@Wurstsemmel%3E
>
> AFAICS he did not get an answer. Is this a known issue? What can I do
> other than doing what copyField should do in my application?
>
> I am using solr 4.0.0.
>
> Thanks,
>
> Robert 


Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Robert Krüger <kr...@lesspain.de>.
On Thu, Jun 6, 2013 at 1:52 PM, Jack Krupansky <ja...@basetechnology.com> wrote:
> "read current state, manipulate fields and then add the document with the
> same id)"
>
> Ahh... then you have an IMPLICIT reference to the field in your Java code -
> you explicitly told Solr that you wanted to start with all existing field
> values. Just because a field is the target of a copyField doesn't make it
> any different from any other field when reading. Although, it does beg the
> question of whether or not this field should be stored or not - that's a
> data modeling question that only you can resolve. Do queries need to
> retrieve this field?
you're right. in my concrete use case it does not need to to be stored.


>
> Be sure to null out any values for any fields that are sourced by copy
> fields. Otherwise, yes, duplicated values would be exactly what you should
> expect.
yes, I will do that.

>
> Is there any reason that you can't simply use atomic update - create a new
> document with the same document id but with only "set" values for the fields
> to be changed? There is also "add" for multivalued fields.
>
> There isn't great doc for this. Basically, the value for every non-ID field
> would be a Map object (HashMap) with a "set" key whose value is the new
> field value.
>
> Here's a code fragment for setting one field:
>
>    SolrInputDocument doc2 = new SolrInputDocument();
>    Map<String,String> fpValue2 = new HashMap<String, String>();
>    fpValue2.put("set","fp2");
>    doc2.setField("FACTURES_PRODUIT", fpValue2);
>
> You need a separate Map object for each field to be set or "add"ed for
> appending to a multivalued field. And you need a simple (non-Map) value for
> your ID field.

thanks for the info! the code is a lot older than solr 4.0, so that
option was not available at the time of its writing. I will check if
it makes sense to use that feature. most likely yes.

Robert

Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Jack Krupansky <ja...@basetechnology.com>.
"read current state, manipulate fields and then add the document with the 
same id)"

Ahh... then you have an IMPLICIT reference to the field in your Java code - 
you explicitly told Solr that you wanted to start with all existing field 
values. Just because a field is the target of a copyField doesn't make it 
any different from any other field when reading. Although, it does beg the 
question of whether or not this field should be stored or not - that's a 
data modeling question that only you can resolve. Do queries need to 
retrieve this field?

Be sure to null out any values for any fields that are sourced by copy 
fields. Otherwise, yes, duplicated values would be exactly what you should 
expect.

Is there any reason that you can't simply use atomic update - create a new 
document with the same document id but with only "set" values for the fields 
to be changed? There is also "add" for multivalued fields.

There isn't great doc for this. Basically, the value for every non-ID field 
would be a Map object (HashMap) with a "set" key whose value is the new 
field value.

Here's a code fragment for setting one field:

    SolrInputDocument doc2 = new SolrInputDocument();
    Map<String,String> fpValue2 = new HashMap<String, String>();
    fpValue2.put("set","fp2");
    doc2.setField("FACTURES_PRODUIT", fpValue2);

You need a separate Map object for each field to be set or "add"ed for 
appending to a multivalued field. And you need a simple (non-Map) value for 
your ID field.

-- Jack Krupansky

-----Original Message----- 
From: Robert Krüger
Sent: Thursday, June 06, 2013 7:25 AM
To: solr-user@lucene.apache.org
Subject: Re: copyField generates "multiple values encountered for non 
multiValued field"

I don't know what I have to do to use the atomic update feature but I
am not aware of using it. But the way you describe it, it means that
the copyField directive does not overwrite the existing field content
and that's an easy explanation to what is happening in my case. Then
the second update (which I do manually, i.e. read current state,
manipulate fields and then add the document with the same id) will
lead to this. That was not so obvious to me from the docs.

Thanks,

Robert

On Thu, Jun 6, 2013 at 12:18 AM, Chris Hostetter
<ho...@fucit.org> wrote:
>
> : I updated the Index using SolrJ and got the exact same error message
>
> there aren't a lot of specifics provided in this thread, so this may not
> be applicable, but if you mean you actaully using the "atomic updates"
> feature to update an existing document then the problem is that you still
> have the existing value in your name2 field, as well as another copy of
> the "name" field evaluated by copyField after the updates are applied...
>
> http://wiki.apache.org/solr/Atomic_Updates#Stored_Values
>
>
> -Hoss 


Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Robert Krüger <kr...@lesspain.de>.
I don't know what I have to do to use the atomic update feature but I
am not aware of using it. But the way you describe it, it means that
the copyField directive does not overwrite the existing field content
and that's an easy explanation to what is happening in my case. Then
the second update (which I do manually, i.e. read current state,
manipulate fields and then add the document with the same id) will
lead to this. That was not so obvious to me from the docs.

Thanks,

Robert

On Thu, Jun 6, 2013 at 12:18 AM, Chris Hostetter
<ho...@fucit.org> wrote:
>
> : I updated the Index using SolrJ and got the exact same error message
>
> there aren't a lot of specifics provided in this thread, so this may not
> be applicable, but if you mean you actaully using the "atomic updates"
> feature to update an existing document then the problem is that you still
> have the existing value in your name2 field, as well as another copy of
> the "name" field evaluated by copyField after the updates are applied...
>
> http://wiki.apache.org/solr/Atomic_Updates#Stored_Values
>
>
> -Hoss

Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Chris Hostetter <ho...@fucit.org>.
: I updated the Index using SolrJ and got the exact same error message

there aren't a lot of specifics provided in this thread, so this may not 
be applicable, but if you mean you actaully using the "atomic updates" 
feature to update an existing document then the problem is that you still 
have the existing value in your name2 field, as well as another copy of 
the "name" field evaluated by copyField after the updates are applied...

http://wiki.apache.org/solr/Atomic_Updates#Stored_Values


-Hoss

Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Robert Krüger <kr...@lesspain.de>.
OK, I have two fields defined as follows:

  <field name="name"   type="string"   indexed="true"  stored="true"
multiValued="false" />
  <field name="name2"   type="string_ci"   indexed="true"
stored="true"  multiValued="false" />

and this copyField directive

 <copyField source="name" dest="name2"/>

I updated the Index using SolrJ and got the exact same error message
that is in the subject. However, while waiting for feedback I built a
workaround at the application level and now reconstructing the
original state, to be able to answer you, I have different behaviour.
What happens now is that the field "name2" is populated with multiple
values although it is not defined as multiValued (see above).

Although this is strange, it is consistent with the earlier problem in
that copyField does not seem to overwrite the existing field values. I
may be using it incorrectly (it's the first time I am using copyField)
but the docs in the wiki did not say anything about an overwrite
option.

Cheers,

Robert


On Wed, Jun 5, 2013 at 5:16 PM, Jack Krupansky <ja...@basetechnology.com> wrote:
> Try describing your own symptom in your own words - because his issue
> related to Solr 1.4. I mean, where exactly are you setting
> "allowDuplicates=false"?? And why do you think it has anything to do with
> adding documents to Solr? Solr 1.4 did not have atomic update, so sending
> the exact same document twice would not result in a change in the index
> (unless you had a date field with a value of "NOW".) Copy field only uses
> values from the current document.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Robert Krüger
> Sent: Wednesday, June 05, 2013 10:37 AM
> To: solr-user@lucene.apache.org
> Subject: copyField generates "multiple values encountered for non
> multiValued field"
>
>
> I have the exact same problem as the guy here:
>
> http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201105.mbox/%3C3A2B3E42FCAA4BF496AE625426C5C6E4@Wurstsemmel%3E
>
> AFAICS he did not get an answer. Is this a known issue? What can I do
> other than doing what copyField should do in my application?
>
> I am using solr 4.0.0.
>
> Thanks,
>
> Robert

Re: copyField generates "multiple values encountered for non multiValued field"

Posted by Jack Krupansky <ja...@basetechnology.com>.
Try describing your own symptom in your own words - because his issue 
related to Solr 1.4. I mean, where exactly are you setting 
"allowDuplicates=false"?? And why do you think it has anything to do with 
adding documents to Solr? Solr 1.4 did not have atomic update, so sending 
the exact same document twice would not result in a change in the index 
(unless you had a date field with a value of "NOW".) Copy field only uses 
values from the current document.

-- Jack Krupansky

-----Original Message----- 
From: Robert Krüger
Sent: Wednesday, June 05, 2013 10:37 AM
To: solr-user@lucene.apache.org
Subject: copyField generates "multiple values encountered for non 
multiValued field"

I have the exact same problem as the guy here:

http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201105.mbox/%3C3A2B3E42FCAA4BF496AE625426C5C6E4@Wurstsemmel%3E

AFAICS he did not get an answer. Is this a known issue? What can I do
other than doing what copyField should do in my application?

I am using solr 4.0.0.

Thanks,

Robert