Update Document

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

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 <
alexandre.gerlic@gmail.com> 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

2010/4/15 Berkay Mollamustafaoglu mberkay@gmail.com:

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
alexandre.gerlic@gmail.com 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

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.

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
clinton@iannounce.co.ukwrote:

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.