mapper-size.asciidoc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. [[mapper-size]]
  2. === Mapper Size Plugin
  3. The mapper-size plugin provides the `_size` meta field which, when enabled,
  4. indexes the size in bytes of the original
  5. {ref}/mapping-source-field.html[`_source`] field.
  6. [[mapper-size-install]]
  7. [float]
  8. ==== Installation
  9. This plugin can be installed using the plugin manager:
  10. [source,sh]
  11. ----------------------------------------------------------------
  12. sudo bin/elasticsearch-plugin install mapper-size
  13. ----------------------------------------------------------------
  14. The plugin must be installed on every node in the cluster, and each node must
  15. be restarted after installation.
  16. [[mapper-size-remove]]
  17. [float]
  18. ==== Removal
  19. The plugin can be removed with the following command:
  20. [source,sh]
  21. ----------------------------------------------------------------
  22. sudo bin/elasticsearch-plugin remove mapper-size
  23. ----------------------------------------------------------------
  24. The node must be stopped before removing the plugin.
  25. [[mapper-size-usage]]
  26. ==== Using the `_size` field
  27. In order to enable the `_size` field, set the mapping as follows:
  28. [source,js]
  29. --------------------------
  30. PUT my_index
  31. {
  32. "mappings": {
  33. "my_type": {
  34. "_size": {
  35. "enabled": true
  36. }
  37. }
  38. }
  39. }
  40. --------------------------
  41. // CONSOLE
  42. The value of the `_size` field is accessible in queries:
  43. [source,js]
  44. --------------------------
  45. # Example documents
  46. PUT my_index/my_type/1
  47. {
  48. "text": "This is a document"
  49. }
  50. PUT my_index/my_type/2
  51. {
  52. "text": "This is another document"
  53. }
  54. GET my_index/_search
  55. {
  56. "query": {
  57. "range": {
  58. "_size": { <1>
  59. "gt": 10
  60. }
  61. }
  62. }
  63. }
  64. --------------------------
  65. // CONSOLE
  66. // TEST[continued]
  67. <1> Querying on the `_size` field