all-field.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. [[mapping-all-field]]
  2. === `_all`
  3. The idea of the `_all` field is that it includes the text of one or more
  4. other fields within the document indexed. It can come very handy
  5. especially for search requests, where we want to execute a search query
  6. against the content of a document, without knowing which fields to
  7. search on. This comes at the expense of CPU cycles and index size.
  8. The `_all` fields can be completely disabled. Explicit field mapping and
  9. object mapping can be excluded / included in the `_all` field. By
  10. default, it is enabled and all fields are included in it for ease of
  11. use.
  12. When disabling the `_all` field, it is a good practice to set
  13. `index.query.default_field` to a different value (for example, if you
  14. have a main "message" field in your data, set it to `message`).
  15. One of the nice features of the `_all` field is that it takes into
  16. account specific fields boost levels. Meaning that if a title field is
  17. boosted more than content, the title (part) in the `_all` field will
  18. mean more than the content (part) in the `_all` field.
  19. Here is a sample mapping:
  20. [source,js]
  21. --------------------------------------------------
  22. {
  23. "person" : {
  24. "_all" : {"enabled" : true},
  25. "properties" : {
  26. "name" : {
  27. "type" : "object",
  28. "dynamic" : false,
  29. "properties" : {
  30. "first" : {"type" : "string", "store" : "yes", "include_in_all" : false},
  31. "last" : {"type" : "string", "index" : "not_analyzed"}
  32. }
  33. },
  34. "address" : {
  35. "type" : "object",
  36. "include_in_all" : false,
  37. "properties" : {
  38. "first" : {
  39. "properties" : {
  40. "location" : {"type" : "string", "store" : "yes", "index_name" : "firstLocation"}
  41. }
  42. },
  43. "last" : {
  44. "properties" : {
  45. "location" : {"type" : "string"}
  46. }
  47. }
  48. }
  49. },
  50. "simple1" : {"type" : "long", "include_in_all" : true},
  51. "simple2" : {"type" : "long", "include_in_all" : false}
  52. }
  53. }
  54. }
  55. --------------------------------------------------
  56. The `_all` fields allows for `store`, `term_vector` and `analyzer` (with
  57. specific `index_analyzer` and `search_analyzer`) to be set.
  58. [float]
  59. [[highlighting]]
  60. ==== Highlighting
  61. For any field to allow
  62. <<search-request-highlighting,highlighting>> it has
  63. to be either stored or part of the `_source` field. By default `_all`
  64. field does not qualify for either, so highlighting for it does not yield
  65. any data.
  66. Although it is possible to `store` the `_all` field, it is basically an
  67. aggregation of all fields, which means more data will be stored, and
  68. highlighting it might produce strange results.