# Index with different document types

**URL:** <https://discuss.elastic.co/t/index-with-different-document-types/341984>\
**Category:** Elasticsearch\
**Created:** [August 30, 2023, 1:03pm UTC](https://discuss.elastic.co/t/index-with-different-document-types/341984 "2023-08-30T13:03:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktech007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ktech007/32/124751_2.png) [@ktech007](https://discuss.elastic.co/u/ktech007)\
**Post date:** [August 30, 2023, 1:03pm UTC](https://discuss.elastic.co/t/index-with-different-document-types/341984/1 "2023-08-30T13:03:29Z")

</div>

Hello,

Suppose I have in total 3000 mappings (mix of text, date, numerics) for an index and have documents using a subset of those mappings like this:

```auto
doc1 {
  field_1 ...
  field_2 ...
  field_3 ...
}

doc2 {
  field_3..
  field_100...
}

doc3{
  field_1
  field_100
  field_200
  field_1010
}

```

- Is this pattern recommended for a single index or multiple indices would be better w/ alias? The examples I see are usually adding one type of document to an index, so wondering if there is any performance benefit here.
- What about dynamic vs static mapping? Any difference it has on indexing?

---

<div class="post-metadata">

**Author:** ![Alexis\_Roberson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexis_roberson/32/113233_2.png) [@Alexis\_Roberson](https://discuss.elastic.co/u/Alexis_Roberson)\
**Post date:** [August 30, 2023, 3:42pm UTC](https://discuss.elastic.co/t/index-with-different-document-types/341984/2 "2023-08-30T15:42:12Z")

</div>

@ktech007 With dynamic mapping, Elasticsearch defines your mapping based on the structure of your incoming documents. This is helpful for exploring data even when you don't have the structure ahead of time. With explicit mapping, it allows you to have more control over how your documents will be structured. Here, you define the mapping that will be applied to all incoming documents.  
Whether you use explicit or dynamic, the mapping is set upon ingestion and cannot be changed. If you want the documents to be structured in three different ways then that would require three different indices with their on corresponding mappings. Each index will have its own single mapping.

---

<div class="post-metadata">

**Author:** ![linkerc](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@linkerc](https://discuss.elastic.co/u/linkerc)\
**Post date:** [August 30, 2023, 9:31pm UTC](https://discuss.elastic.co/t/index-with-different-document-types/341984/3 "2023-08-30T21:31:50Z")

</div>

I think most people put "similar" documents in one index.  
The main purpose is to be able to search for most relevant documents with the smallest set, which produces the fastest query.  
And grouping similar documents into one index achieves this goal.

It's really your call on how you want to break up this logical set. And it often changes when your document count grows.

---

<div class="post-metadata">

**Author:** ![ktech007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ktech007/32/124751_2.png) [@ktech007](https://discuss.elastic.co/u/ktech007)\
**Post date:** [August 31, 2023, 1:21am UTC](https://discuss.elastic.co/t/index-with-different-document-types/341984/4 "2023-08-31T01:21:16Z")

</div>

sounds good. thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 28, 2023, 1:21am UTC](https://discuss.elastic.co/t/index-with-different-document-types/341984/5 "2023-09-28T01:21:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
