Index definition with range fields

Hello!

I’m currently trying to improve some index definitions at my job, and i got a situation that impact how we use “ESR” rule. Our use case got 2 range fields that could be selected into the same Query or separately, and such range fields could impact on how to use ESR Rule.

I have five fields that have the following specification:

  • customer_name: String;
    • Predefined values (e.g. customer_a, customer_b, customer_c);
    • Only one value per query;
    • Required value, some value must be chose by user;
  • order_date: Date;
    • Optional value;
    • If user didn’t select any value, system must query for all dates available for selected customer_name;
  • state: String;
    • Predefined values (e.g. SP, RJ, MG);
    • Multiple values could be selected;
    • If user didn’t select any value, system must query for all state available;
  • status: String;
    • Predefined values (e.g. delivered, cancelled, declined, etc…);
    • Multiple values could be selected;
    • If user didn’t select any value, must query for all status available;
  • has_discount: Boolean;
    • Optional field;
    • If user didn’t select any value, must query for true and false values;

And my index definition is:

customer_name_1_order_date_-1_state_1_status_1_has_discount_1


Questions:

  1. Is there any tip for use cases with more than one range fields in the same index?

  2. Is there any “automatic” form to select all values available for a specific range field?

Context for the second question: Sometimes my users didn’t chose any ‘state field’ to query but chose some status.
In the above context, we would like to query for all available state, without list it manually in programming language.