lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessandro Benedetti <benedetti.ale...@gmail.com>
Subject Re: Does update field feature work in a schema with dynamic fields?
Date Wed, 15 Jul 2015 14:39:52 GMT
Hey Shawn, I was debugging a little bit,this is the problem :

When adding a field from the solr document, to the Lucene one, even if this
document was previously added by the execution of the copy field
instruction to the Lucene Document, this check is carried :

org/apache/solr/update/DocumentBuilder.java:89

// Make sure it has the correct number
if( sfield!=null && !sfield.multiValued() && field.getValueCount() > 1
) {
  throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
      "ERROR: "+getID(doc, schema)+"multiple values encountered for
non multiValued field " +
        sfield.getName() + ": " +field.getValue() );
}


This will actually check the Solr Document field.getValueCount(),
ignoring the fact that the field was already added to the Lucene
Document to be indexed.

So the field will be added again.

I understand that doesn't make a lot of sense to store a copy field (
nothing will change from the source field stored content).

But I guess we should try to avoid this anomalies.

The simple solution should be to not execute any copy field
instruction in an updatedDocument.

Unfortunately we don't have any signal in the DocumentBuilder at that
point, that will let us know if the Document is a new one or an
updated one.

What do you think?

Will be easy to have the Document builder aware if it is an add or an
update, and react ?

If not we need to think something else.


Cheers





2015-07-15 15:25 GMT+01:00 Shawn Heisey <apache@elyograg.org>:

> On 7/15/2015 3:01 AM, Martínez López, Alfonso wrote:
> > <!--Fields-->
> > <field name="id" type="string" indexed="true" stored="true"
> required="true" />
> > <field name="name" type="string" indexed="true" stored="true" />
> > <field name="src_desc" type="string" indexed="true" stored="true" />
> > <field name="_version_" type="long" indexed="true" stored="true" /
> > <!--Dynamic fields definition-->
> > <dynamicField name="src_*" type="string" indexed="true" stored="true"
> multiValued="false" />
> > <dynamicField name="dinamic_*" type="string" indexed="true"
> stored="true" multiValued="false" />
> > <!--Copy fields-->
> > <copyField source="src_*" dest="dinamic_*"/>
>
> <snip>
>
> > And later I update the field 'name' with this command:
> >
> > curl http://<solr_host>:<sorl_port>/solr/default/update?commit=true
-H
> "Content-Type: text/xml" --data-binary '<add><doc><field
> name="id">1</field><field name="name"
> update="set">paquico</field></doc></add>'
> >
> > As I do so the doc i retrive from Solr is:
> >
> > <result name="response" numFound="1" start="0" maxScore="1.0">
> >  <doc>
> >   <str name="id">1</str>
> >   <str name="name">paquico</str>
> >   <str name="src_desc">friend of mine</str>
> >   <arr name="dinamic_desc">
> >    <str>friend of mine</str>
> >    <str>friend of mine</str>
> >   </arr>
> >   <long name="_version_">1506750859550130176</long>
> >   <float name="score">1.0</float>
> >  </doc>
> > </result>
>
> The problem here is that the copyField destination is stored, so you get
> the original value of the destination field plus another copy from
> src_desc.
>
> If you look carefully at the "caveats and limitations" for Atomic
> Updates, you will see that all copyField destinations must be unstored
> for proper operation:
>
> https://wiki.apache.org/solr/Atomic_Updates#Caveats_and_Limitations
>
> It appears that this information was *NOT* in the Solr Reference Guide,
> so I updated the reference guide to include it.
>
>
> https://cwiki.apache.org/confluence/display/solr/Updating+Parts+of+Documents
>
> Here's a question for those with more expertise than me:  If a copyField
> destination were stored, but not multiValued, and an atomic update was
> attempted, would the update fail entirely?  I suspect it would, and I'd
> like to make the ref guide info as accurate as I can.
>
> Thanks,
> Shawn
>
>


-- 
--------------------------

Benedetti Alessandro
Visiting card - http://about.me/alessandro_benedetti
Blog - http://alexbenedetti.blogspot.co.uk

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message