usage.asciidoc 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[transform-usage]]
  4. === When to use {transforms}
  5. {es} aggregations are a powerful and flexible feature that enable you to
  6. summarize and retrieve complex insights about your data. You can summarize
  7. complex things like the number of web requests per day on a busy website, broken
  8. down by geography and browser type. If you use the same data set to try to
  9. calculate something as simple as a single number for the average duration of
  10. visitor web sessions, however, you can quickly run out of memory.
  11. Why does this occur? A web session duration is an example of a behavioral
  12. attribute not held on any one log record; it has to be derived by finding the
  13. first and last records for each session in our weblogs. This derivation requires
  14. some complex query expressions and a lot of memory to connect all the data
  15. points. If you have an ongoing background process that fuses related events from
  16. one index into entity-centric summaries in another index, you get a more useful,
  17. joined-up picture. This new index is sometimes referred to as a _{dataframe}_.
  18. You might want to consider using {transforms} instead of aggregations when:
  19. * You need a complete _feature index_ rather than a top-N set of items.
  20. +
  21. In {ml}, you often need a complete set of behavioral features rather just the
  22. top-N. For example, if you are predicting customer churn, you might look at
  23. features such as the number of website visits in the last week, the total number
  24. of sales, or the number of emails sent. The {stack} {ml-features} create models
  25. based on this multi-dimensional feature space, so they benefit from the full
  26. feature indices that are created by {transforms}.
  27. +
  28. This scenario also applies when you are trying to search across the results of
  29. an aggregation or multiple aggregations. Aggregation results can be ordered or
  30. filtered, but there are
  31. {ref}/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order[limitations to ordering]
  32. and
  33. {ref}/search-aggregations-pipeline-bucket-selector-aggregation.html[filtering by bucket selector]
  34. is constrained by the maximum number of buckets returned. If you want to search
  35. all aggregation results, you need to create the complete {dataframe}. If you
  36. need to sort or filter the aggregation results by multiple fields, {transforms}
  37. are particularly useful.
  38. * You need to sort aggregation results by a pipeline aggregation.
  39. +
  40. {ref}/search-aggregations-pipeline.html[Pipeline aggregations] cannot be used
  41. for sorting. Technically, this is because pipeline aggregations are run during
  42. the reduce phase after all other aggregations have already completed. If you
  43. create a {transform}, you can effectively perform multiple passes over the data.
  44. * You want to create summary tables to optimize queries.
  45. +
  46. For example, if you
  47. have a high level dashboard that is accessed by a large number of users and it
  48. uses a complex aggregation over a large dataset, it may be more efficient to
  49. create a {transform} to cache results. Thus, each user doesn't need to run the
  50. aggregation query.