Update Document

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Update Document

alexandre gerlic
Hi,

I would like to know if it is possible to update a document, for
example replace or add a field ?
I found optype = create but it seems to be the only solution.

Thanks

--
Alexandre Gerlic
Reply | Threaded
Open this post in threaded view
|

Re: Update Document

Berkay Mollamustafaoglu-2
The default index command updates the document if it exists. optype create just says don't check whether it exists to improve performance. So if you want to update the doc, I think you just index it again. 

Regards,
Berkay Mollamustafaoglu
mberkay on yahoo, google and skype


On Thu, Apr 15, 2010 at 4:28 PM, alexandre gerlic <[hidden email]> wrote:
Hi,

I would like to know if it is possible to update a document, for
example replace or add a field ?
I found optype = create but it seems to be the only solution.

Thanks

--
Alexandre Gerlic

Reply | Threaded
Open this post in threaded view
|

Re: Update Document

alexandre gerlic
2010/4/15 Berkay Mollamustafaoglu <[hidden email]>:
> The default index command updates the document if it exists. optype create
> just says don't check whether it exists to improve performance. So if you
> want to update the doc, I think you just index it again.
> Regards,
> Berkay Mollamustafaoglu

Thanks, I found also this in put mapping section :
"When an existing mapping already exists under the given type, the two
mapping definitions, the one already defined, and the new ones are
merged."


> mberkay on yahoo, google and skype
>
>
> On Thu, Apr 15, 2010 at 4:28 PM, alexandre gerlic
> <[hidden email]> wrote:
>>
>> Hi,
>>
>> I would like to know if it is possible to update a document, for
>> example replace or add a field ?
>> I found optype = create but it seems to be the only solution.
>>
>> Thanks
>>
>> --
>> Alexandre Gerlic
>
>



--
Alexandre Gerlic
Reply | Threaded
Open this post in threaded view
|

Re: Update Document

Clinton Gormley

> Thanks, I found also this in put mapping section :
> "When an existing mapping already exists under the given type, the two
> mapping definitions, the one already defined, and the new ones are
> merged."

...if they can be

If you have a field defined as 'string', then you want to change it to
'date', you can't do that.  You would need to create a new mapping and
reindex all the existing documents.

I have it working as follows:

  - my app uses index 'xyz'
  - 'xyz' is an alias for 'xyz_1234'

if I want to change the mapping:
  - I create 'xyz_1235'
  - read all docs from 'xyz_1234' -> index to 'xyz_1235'
  - update alias 'xyz' to point to 'xyz_1235'
  - delete index 'xyz_1234'

--
Web Announcements Limited is a company registered in England and Wales,
with company number 05608868, with registered address at 10 Arvon Road,
London, N5 1PR.

Reply | Threaded
Open this post in threaded view
|

Re: Update Document

kimchy
Administrator
Note that this are two different things, updating the mapping and updating a document instance.

cheer,
shay.banon

On Fri, Apr 16, 2010 at 12:29 AM, Clinton Gormley <[hidden email]> wrote:

> Thanks, I found also this in put mapping section :
> "When an existing mapping already exists under the given type, the two
> mapping definitions, the one already defined, and the new ones are
> merged."

...if they can be

If you have a field defined as 'string', then you want to change it to
'date', you can't do that.  You would need to create a new mapping and
reindex all the existing documents.

I have it working as follows:

 - my app uses index 'xyz'
 - 'xyz' is an alias for 'xyz_1234'

if I want to change the mapping:
 - I create 'xyz_1235'
 - read all docs from 'xyz_1234' -> index to 'xyz_1235'
 - update alias 'xyz' to point to 'xyz_1235'
 - delete index 'xyz_1234'

--
Web Announcements Limited is a company registered in England and Wales,
with company number 05608868, with registered address at 10 Arvon Road,
London, N5 1PR.