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 Dikchant Sahi <co...@gmail.com> on 2012/12/18 08:20:14 UTC

Solr atomic update of multi-valued field

Hi,

Does Solr 4.0 allows to update the values of multi-valued field? Say I have
list of values for skills field like java, j2ee and i want to change it
to solr, lucene.

I was trying to play with atomic updates and below is my observation:

I have following document in my index:
<doc>
<str name="id">1</str>
<str name="name">Dikchant</str>
<str name="profession">software engineer</str>
<arr name="skills">
<str>java</str>
<str>j2ee</str>
</arr>
</doc>

To update the skills to solr, lucene, I indexed document as follows:

*<add>*
*  <doc>*
*    <field name="id">1</field>*
*    <field name="skills" update="set">solr</field>*
*    <field name="skills" update="set">lucene</field>*
*  </doc>*
*</add>*

The document added to index is as follows:
*<doc>*
*  <str name="id">1</str>*
*  <arr name="skills">*
*    <str>{set=solr}</str>*
*    <str>{set=lucene}</str>*
*  </arr>*
*</doc>*

This is not what I was looking for. I found 2 issues:
1. The value of name field was lost
2. The skills fields had some junks like *{set=solr}*
*
*
*
*
Then, to achieve my goal, I tried something different. I tried setting some
single valued field with update="set" parameter to the same value and also
provided the values of multi-valued field as we do while adding new
document.
<add>
  <doc>
    <field name="id">1</field>
    *<field name="name" update="set">Dikchant</field>*
    <field name="skills">solr</field>
    <field name="skills">lucene</field>
  </doc>
</add>

With this the index looks as follows:
<doc>
<str name="id">1</str>
<str name="name">Dikchant</str>
<str name="profession">software engineer</str>
<arr name="skills">
<str>solr</str>
<str>lucene</str>
</arr>
</doc>

The values of multivalued field is changed and value of other field is not
deleted.

The question that comes to my mind is, does Solr 4.0 allows update of
multi-valued field? if yes, is this how it works or am I doing something
wrong?

Regards,
Dikchant

Re: Solr atomic update of multi-valued field

Posted by Erick Erickson <er...@gmail.com>.
Just saw this:

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

so I don't think you can do what you want currently without the patch.

Erick


On Fri, Dec 21, 2012 at 7:58 AM, Erick Erickson <er...@gmail.com>wrote:

> Hmmm, looks like it might be a bug, but I don't know that code at all.
> Wonder what Yonik would have to say....
>
>
> On Wed, Dec 19, 2012 at 9:52 AM, Dikchant Sahi <co...@gmail.com>wrote:
>
>> Hi Erick,
>>
>> The name field is stored. I experience problem only when I update
>> multiValued field with multiple values like,
>> * <field name="skills" update="set">solr</field>*
>> * <field name="skills" update="set">lucene</field>*
>> *
>> *
>> It works perfect, when I set single value for multiValued field like,
>> *<field name="skills" update="set">solr</field>*
>>
>> Thanks,
>> Dikchant
>>
>> On Wed, Dec 19, 2012 at 6:25 PM, Erick Erickson <erickerickson@gmail.com
>> >wrote:
>>
>> > FIrst question: Is the "name" field stored (stored="true")? If it isn't,
>> > that would explain your problems with that field. _all_ relevant fields
>> > (i.e. everything not a destination of a copyField) need to be stored for
>> > atomic updates to work.
>> >
>> > Your second problem I'm not sure about. I remember some JIRAs about
>> > multivalued fields and atomic updates, you might get some info from the
>> > JIRAs here: https://issues.apache.org/jira/browse/SOLR
>> >
>> > but updating multiValued fields _should_ work...
>> >
>> > Best
>> > Erick
>> >
>> >
>> > On Tue, Dec 18, 2012 at 2:20 AM, Dikchant Sahi <contactsahi@gmail.com
>> > >wrote:
>> >
>> > > Hi,
>> > >
>> > > Does Solr 4.0 allows to update the values of multi-valued field? Say I
>> > have
>> > > list of values for skills field like java, j2ee and i want to change
>> it
>> > > to solr, lucene.
>> > >
>> > > I was trying to play with atomic updates and below is my observation:
>> > >
>> > > I have following document in my index:
>> > > <doc>
>> > > <str name="id">1</str>
>> > > <str name="name">Dikchant</str>
>> > > <str name="profession">software engineer</str>
>> > > <arr name="skills">
>> > > <str>java</str>
>> > > <str>j2ee</str>
>> > > </arr>
>> > > </doc>
>> > >
>> > > To update the skills to solr, lucene, I indexed document as follows:
>> > >
>> > > *<add>*
>> > > *  <doc>*
>> > > *    <field name="id">1</field>*
>> > > *    <field name="skills" update="set">solr</field>*
>> > > *    <field name="skills" update="set">lucene</field>*
>> > > *  </doc>*
>> > > *</add>*
>> > >
>> > > The document added to index is as follows:
>> > > *<doc>*
>> > > *  <str name="id">1</str>*
>> > > *  <arr name="skills">*
>> > > *    <str>{set=solr}</str>*
>> > > *    <str>{set=lucene}</str>*
>> > > *  </arr>*
>> > > *</doc>*
>> > >
>> > > This is not what I was looking for. I found 2 issues:
>> > > 1. The value of name field was lost
>> > > 2. The skills fields had some junks like *{set=solr}*
>> > > *
>> > > *
>> > > *
>> > > *
>> > > Then, to achieve my goal, I tried something different. I tried setting
>> > some
>> > > single valued field with update="set" parameter to the same value and
>> > also
>> > > provided the values of multi-valued field as we do while adding new
>> > > document.
>> > > <add>
>> > >   <doc>
>> > >     <field name="id">1</field>
>> > >     *<field name="name" update="set">Dikchant</field>*
>> > >     <field name="skills">solr</field>
>> > >     <field name="skills">lucene</field>
>> > >   </doc>
>> > > </add>
>> > >
>> > > With this the index looks as follows:
>> > > <doc>
>> > > <str name="id">1</str>
>> > > <str name="name">Dikchant</str>
>> > > <str name="profession">software engineer</str>
>> > > <arr name="skills">
>> > > <str>solr</str>
>> > > <str>lucene</str>
>> > > </arr>
>> > > </doc>
>> > >
>> > > The values of multivalued field is changed and value of other field is
>> > not
>> > > deleted.
>> > >
>> > > The question that comes to my mind is, does Solr 4.0 allows update of
>> > > multi-valued field? if yes, is this how it works or am I doing
>> something
>> > > wrong?
>> > >
>> > > Regards,
>> > > Dikchant
>> > >
>> >
>>
>
>

Re: Solr atomic update of multi-valued field

Posted by Erick Erickson <er...@gmail.com>.
Hmmm, looks like it might be a bug, but I don't know that code at all.
Wonder what Yonik would have to say....


On Wed, Dec 19, 2012 at 9:52 AM, Dikchant Sahi <co...@gmail.com>wrote:

> Hi Erick,
>
> The name field is stored. I experience problem only when I update
> multiValued field with multiple values like,
> * <field name="skills" update="set">solr</field>*
> * <field name="skills" update="set">lucene</field>*
> *
> *
> It works perfect, when I set single value for multiValued field like,
> *<field name="skills" update="set">solr</field>*
>
> Thanks,
> Dikchant
>
> On Wed, Dec 19, 2012 at 6:25 PM, Erick Erickson <erickerickson@gmail.com
> >wrote:
>
> > FIrst question: Is the "name" field stored (stored="true")? If it isn't,
> > that would explain your problems with that field. _all_ relevant fields
> > (i.e. everything not a destination of a copyField) need to be stored for
> > atomic updates to work.
> >
> > Your second problem I'm not sure about. I remember some JIRAs about
> > multivalued fields and atomic updates, you might get some info from the
> > JIRAs here: https://issues.apache.org/jira/browse/SOLR
> >
> > but updating multiValued fields _should_ work...
> >
> > Best
> > Erick
> >
> >
> > On Tue, Dec 18, 2012 at 2:20 AM, Dikchant Sahi <contactsahi@gmail.com
> > >wrote:
> >
> > > Hi,
> > >
> > > Does Solr 4.0 allows to update the values of multi-valued field? Say I
> > have
> > > list of values for skills field like java, j2ee and i want to change it
> > > to solr, lucene.
> > >
> > > I was trying to play with atomic updates and below is my observation:
> > >
> > > I have following document in my index:
> > > <doc>
> > > <str name="id">1</str>
> > > <str name="name">Dikchant</str>
> > > <str name="profession">software engineer</str>
> > > <arr name="skills">
> > > <str>java</str>
> > > <str>j2ee</str>
> > > </arr>
> > > </doc>
> > >
> > > To update the skills to solr, lucene, I indexed document as follows:
> > >
> > > *<add>*
> > > *  <doc>*
> > > *    <field name="id">1</field>*
> > > *    <field name="skills" update="set">solr</field>*
> > > *    <field name="skills" update="set">lucene</field>*
> > > *  </doc>*
> > > *</add>*
> > >
> > > The document added to index is as follows:
> > > *<doc>*
> > > *  <str name="id">1</str>*
> > > *  <arr name="skills">*
> > > *    <str>{set=solr}</str>*
> > > *    <str>{set=lucene}</str>*
> > > *  </arr>*
> > > *</doc>*
> > >
> > > This is not what I was looking for. I found 2 issues:
> > > 1. The value of name field was lost
> > > 2. The skills fields had some junks like *{set=solr}*
> > > *
> > > *
> > > *
> > > *
> > > Then, to achieve my goal, I tried something different. I tried setting
> > some
> > > single valued field with update="set" parameter to the same value and
> > also
> > > provided the values of multi-valued field as we do while adding new
> > > document.
> > > <add>
> > >   <doc>
> > >     <field name="id">1</field>
> > >     *<field name="name" update="set">Dikchant</field>*
> > >     <field name="skills">solr</field>
> > >     <field name="skills">lucene</field>
> > >   </doc>
> > > </add>
> > >
> > > With this the index looks as follows:
> > > <doc>
> > > <str name="id">1</str>
> > > <str name="name">Dikchant</str>
> > > <str name="profession">software engineer</str>
> > > <arr name="skills">
> > > <str>solr</str>
> > > <str>lucene</str>
> > > </arr>
> > > </doc>
> > >
> > > The values of multivalued field is changed and value of other field is
> > not
> > > deleted.
> > >
> > > The question that comes to my mind is, does Solr 4.0 allows update of
> > > multi-valued field? if yes, is this how it works or am I doing
> something
> > > wrong?
> > >
> > > Regards,
> > > Dikchant
> > >
> >
>

Re: Solr atomic update of multi-valued field

Posted by Dikchant Sahi <co...@gmail.com>.
Hi Erick,

The name field is stored. I experience problem only when I update
multiValued field with multiple values like,
* <field name="skills" update="set">solr</field>*
* <field name="skills" update="set">lucene</field>*
*
*
It works perfect, when I set single value for multiValued field like,
*<field name="skills" update="set">solr</field>*

Thanks,
Dikchant

On Wed, Dec 19, 2012 at 6:25 PM, Erick Erickson <er...@gmail.com>wrote:

> FIrst question: Is the "name" field stored (stored="true")? If it isn't,
> that would explain your problems with that field. _all_ relevant fields
> (i.e. everything not a destination of a copyField) need to be stored for
> atomic updates to work.
>
> Your second problem I'm not sure about. I remember some JIRAs about
> multivalued fields and atomic updates, you might get some info from the
> JIRAs here: https://issues.apache.org/jira/browse/SOLR
>
> but updating multiValued fields _should_ work...
>
> Best
> Erick
>
>
> On Tue, Dec 18, 2012 at 2:20 AM, Dikchant Sahi <contactsahi@gmail.com
> >wrote:
>
> > Hi,
> >
> > Does Solr 4.0 allows to update the values of multi-valued field? Say I
> have
> > list of values for skills field like java, j2ee and i want to change it
> > to solr, lucene.
> >
> > I was trying to play with atomic updates and below is my observation:
> >
> > I have following document in my index:
> > <doc>
> > <str name="id">1</str>
> > <str name="name">Dikchant</str>
> > <str name="profession">software engineer</str>
> > <arr name="skills">
> > <str>java</str>
> > <str>j2ee</str>
> > </arr>
> > </doc>
> >
> > To update the skills to solr, lucene, I indexed document as follows:
> >
> > *<add>*
> > *  <doc>*
> > *    <field name="id">1</field>*
> > *    <field name="skills" update="set">solr</field>*
> > *    <field name="skills" update="set">lucene</field>*
> > *  </doc>*
> > *</add>*
> >
> > The document added to index is as follows:
> > *<doc>*
> > *  <str name="id">1</str>*
> > *  <arr name="skills">*
> > *    <str>{set=solr}</str>*
> > *    <str>{set=lucene}</str>*
> > *  </arr>*
> > *</doc>*
> >
> > This is not what I was looking for. I found 2 issues:
> > 1. The value of name field was lost
> > 2. The skills fields had some junks like *{set=solr}*
> > *
> > *
> > *
> > *
> > Then, to achieve my goal, I tried something different. I tried setting
> some
> > single valued field with update="set" parameter to the same value and
> also
> > provided the values of multi-valued field as we do while adding new
> > document.
> > <add>
> >   <doc>
> >     <field name="id">1</field>
> >     *<field name="name" update="set">Dikchant</field>*
> >     <field name="skills">solr</field>
> >     <field name="skills">lucene</field>
> >   </doc>
> > </add>
> >
> > With this the index looks as follows:
> > <doc>
> > <str name="id">1</str>
> > <str name="name">Dikchant</str>
> > <str name="profession">software engineer</str>
> > <arr name="skills">
> > <str>solr</str>
> > <str>lucene</str>
> > </arr>
> > </doc>
> >
> > The values of multivalued field is changed and value of other field is
> not
> > deleted.
> >
> > The question that comes to my mind is, does Solr 4.0 allows update of
> > multi-valued field? if yes, is this how it works or am I doing something
> > wrong?
> >
> > Regards,
> > Dikchant
> >
>

Re: Solr atomic update of multi-valued field

Posted by Erick Erickson <er...@gmail.com>.
FIrst question: Is the "name" field stored (stored="true")? If it isn't,
that would explain your problems with that field. _all_ relevant fields
(i.e. everything not a destination of a copyField) need to be stored for
atomic updates to work.

Your second problem I'm not sure about. I remember some JIRAs about
multivalued fields and atomic updates, you might get some info from the
JIRAs here: https://issues.apache.org/jira/browse/SOLR

but updating multiValued fields _should_ work...

Best
Erick


On Tue, Dec 18, 2012 at 2:20 AM, Dikchant Sahi <co...@gmail.com>wrote:

> Hi,
>
> Does Solr 4.0 allows to update the values of multi-valued field? Say I have
> list of values for skills field like java, j2ee and i want to change it
> to solr, lucene.
>
> I was trying to play with atomic updates and below is my observation:
>
> I have following document in my index:
> <doc>
> <str name="id">1</str>
> <str name="name">Dikchant</str>
> <str name="profession">software engineer</str>
> <arr name="skills">
> <str>java</str>
> <str>j2ee</str>
> </arr>
> </doc>
>
> To update the skills to solr, lucene, I indexed document as follows:
>
> *<add>*
> *  <doc>*
> *    <field name="id">1</field>*
> *    <field name="skills" update="set">solr</field>*
> *    <field name="skills" update="set">lucene</field>*
> *  </doc>*
> *</add>*
>
> The document added to index is as follows:
> *<doc>*
> *  <str name="id">1</str>*
> *  <arr name="skills">*
> *    <str>{set=solr}</str>*
> *    <str>{set=lucene}</str>*
> *  </arr>*
> *</doc>*
>
> This is not what I was looking for. I found 2 issues:
> 1. The value of name field was lost
> 2. The skills fields had some junks like *{set=solr}*
> *
> *
> *
> *
> Then, to achieve my goal, I tried something different. I tried setting some
> single valued field with update="set" parameter to the same value and also
> provided the values of multi-valued field as we do while adding new
> document.
> <add>
>   <doc>
>     <field name="id">1</field>
>     *<field name="name" update="set">Dikchant</field>*
>     <field name="skills">solr</field>
>     <field name="skills">lucene</field>
>   </doc>
> </add>
>
> With this the index looks as follows:
> <doc>
> <str name="id">1</str>
> <str name="name">Dikchant</str>
> <str name="profession">software engineer</str>
> <arr name="skills">
> <str>solr</str>
> <str>lucene</str>
> </arr>
> </doc>
>
> The values of multivalued field is changed and value of other field is not
> deleted.
>
> The question that comes to my mind is, does Solr 4.0 allows update of
> multi-valued field? if yes, is this how it works or am I doing something
> wrong?
>
> Regards,
> Dikchant
>