# Design Index & Document

**URL:** <https://discuss.elastic.co/t/design-index-document/329596>\
**Category:** Elasticsearch\
**Created:** [April 7, 2023, 6:47pm UTC](https://discuss.elastic.co/t/design-index-document/329596 "2023-04-07T18:47:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![YB\_Coding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yb_coding/32/118938_2.png) [@YB\_Coding](https://discuss.elastic.co/u/YB_Coding)\
**Post date:** [April 7, 2023, 6:47pm UTC](https://discuss.elastic.co/t/design-index-document/329596/1 "2023-04-07T18:47:45Z")

</div>

Hello everyone I have a hard time designing my documents. I do not know if I need to create multiple indexes, use nested fieds or index multiple times my documents with a field with a "versionning filter". Below my analogus use case with only one score, in practice I have like 20 scores.

I would like to display roads on a Map. Let's say these roads have a maxSpeed, length and a width properties. I would like to compute a "dangerScore" based on these values AND some input score array for each of them. The dangerScore then would be used to apply a color gradiant on roads. The user can configure the input score array for each of these properties. For example :

- speed \< 30 : 0
- speed [30, 50[ : 5
- speed [50, 80] : 10  
....

dangerScore = max\_speed\_score + length\_score + width\_score

Shoud I index each dangeScore for each configuration in the same document ?

```auto
{

  _id : 0,
  maxSpeed : 50,
  dangerScore_config_0 : 10,
  dangerScore_config_1 : 20,
  ...
}

```

Or should I create versionof my documents per config like

```auto
{
  _id : 0,
  id : 0,
  maxSpeed : 50,
  config : 0,
  dangerScore 10,
  ...
}

```

```auto
{
  _id : 1,
  id : 0,
  maxSpeed : 50,
  config : 1,
  dangerScore 20,
...
}

```

Or shoud I create an Index for each configuration like ?

/index/config\_0

```auto
{
  _id : 0,
  maxSpeed : 50,
  dangerScore : 10
}

```

/index/config\_1

```auto
{
  _id : 0,
  maxSpeed : 50,
  dangerScore : 20
}

```

Or should I have a nested field like ?

```auto
{

  _id : 0
  maxSpeed : 50
  config_0 : {
    dangerScore : 10
  }
  config_1 : {
    dangerScore : 20
  }
...
}

```

Any suggestion ?

Thanks =)

---

<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:** [May 5, 2023, 6:48pm UTC](https://discuss.elastic.co/t/design-index-document/329596/2 "2023-05-05T18:48:43Z")

</div>

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