Having same document id for different document types

(venkata nagaraju buddarapu) #1

My application has a document structure , parts of its changes frequently and others remains same through out document life cycle .

As under hood elastic search update is delete and create new document as lucene segments are immutable ,am planning to have two types for same document , one that changes frequently and other that never changes .

Is it possible to have document with two types pointing to same document

(Mark Walkom) #2

You can have the same ID with different types, yes.
But these will be treated as totally different documents.

(Harlin) #3

I am pretty sure that the document type gets appended onto the ID, so this makes it impossible for two documents to have the same ID

(venkata nagaraju buddarapu) #4

am planning to use nested objects , is it possible just update the nested object to allow not to reindex (delete /create) entire document

(Mark Walkom) #5

Try it;

PUT test-test/

PUT test-test/test/1
  "value": "yes"

PUT test-test/nottest/1
  "value": "no"

GET test-test/nottest/1

GET test-test/test/1

(Mark Walkom) #6

Nesting requires updating the entire document.

(venkata nagaraju buddarapu) #7

I think it can be done with parent - child relation , having the fields that gets changed as a separate types

Do you see any problem having multiple child possibly each field as a separate child

(Harlin) #8

What I mean was that it is impossible for two documents to have the same ID in Lucene since the document type gets appended to its Elasticsearch ID in Lucene.

(venkata nagaraju buddarapu) #9

Agree ,I mean to say that I can avoid elastic search updates (delete and re create) by indexing a child document for every frequently changed field

(system) #10