precision-step.asciidoc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. [[precision-step]]
  2. === `precision_step`
  3. Most <<number,numeric>> datatypes index extra terms representing numeric
  4. ranges for each number to make <<query-dsl-range-query,`range` queries>>
  5. faster. For instance, this `range` query:
  6. [source,js]
  7. --------------------------------------------------
  8. "range": {
  9. "number": {
  10. "gte": 0
  11. "lte": 321
  12. }
  13. }
  14. --------------------------------------------------
  15. might be executed internally as a <<query-dsl-terms-query,`terms` query>> that
  16. looks something like this:
  17. [source,js]
  18. --------------------------------------------------
  19. "terms": {
  20. "number": [
  21. "0-255",
  22. "256-319"
  23. "320",
  24. "321"
  25. ]
  26. }
  27. --------------------------------------------------
  28. These extra terms greatly reduce the number of terms that have to be examined,
  29. at the cost of increased disk space.
  30. The default value for `precision_step` depends on the `type` of the numeric field:
  31. [horizontal]
  32. `long`, `double`, `date`, `ip`:: `16` (3 extra terms)
  33. `integer`, `float`, `short`:: `8` (3 extra terms)
  34. `byte`:: `2147483647` (0 extra terms)
  35. `token_count`:: `32` (0 extra terms)
  36. The value of the `precision_step` setting indicates the number of bits that
  37. should be compressed into an extra term. A `long` value consists of 64 bits,
  38. so a `precision_step` of 16 results in the following terms:
  39. [horizontal]
  40. Bits 0-15:: `value & 1111111111111111 0000000000000000 0000000000000000 0000000000000000`
  41. Bits 0-31:: `value & 1111111111111111 1111111111111111 0000000000000000 0000000000000000`
  42. Bits 0-47:: `value & 1111111111111111 1111111111111111 1111111111111111 0000000000000000`
  43. Bits 0-63:: `value`