Design Index & Document

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 ?

{

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

Or should I create versionof my documents per config like

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

Or shoud I create an Index for each configuration like ?

/index/config_0

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

/index/config_1

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

Or should I have a nested field like ?

{

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

Any suggestion ?

Thanks =)

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