Map a book in elasticsearch with many levels, nested vs parent-child relationship

后端 未结 2 543
再見小時候
再見小時候 2021-01-26 06:09

When creating the mappings for an index that can search through multiple books, is it preferable to use nested mappings like below, or using documents with a parent-child relati

2条回答
  •  鱼传尺愫
    2021-01-26 06:42

    nested is basically a way of stuffing everything into the same document. That can be useful for searching, but it makes certain things considerably harder.

    Like - for example - if you're trying to find a particular chapter section - your query will return the correct document - the whole book. I would imagine that's probably not what you're looking for, and thus a parent/child relationship would be the appropriate way to go.

    Or just don't bother, and treat book/chapter/section as separate types within an index which query and 'join' on demand.

提交回复
热议问题