Document queries

Use queries to get the results you want from document searches

Document queries

Wen working with storages you have no choice but to work with queries. At the start it might look confusing, but once you know the basics, you can create searches that get specific documents or aggregations that gets the average on a field or groups on the different values.

Must, Must Not, Should/or
The chances are one of these will be in the query you make. That is because almost every query option needs to check to something, this can be that the field MUST match to the given value, or the range of the number MUST NOT be between than the given values.


Query term, range, exists

value match with on of
The given field must (not) match with one of the given values in the array. This can be used when you have an array of guid's and you want all of these guid's as results from the result.
Fields accept multiple fields, these fields will create an in-pin depending on what the type it is. You can fill this pin with a value. The document Must (not) have the selected fields with the filled value.
by field dataThis one has the same function as the field the difference is that it accepts custom fields using the fields in-pin, and the values are filled using an object. (like the example on the right).
Date, Number range
This will check if the field is either greater than, less than, or in between the given values. To chose what range to use, you can pull out of the query in-pin and check the available options.



With aggregations you can calculate or group with the results. The aggregation needs to have a name so you can get it from the results. The Sub Agg and the Range Filter are optional and can be used to refine your aggregation.
Min, Max, Avg on field
The name says it all, these aggregations will get the max or min from all the search matches or calculates the average of the results.
group on field
This aggregation will group the results based on the values of the given fields, it will return the value of the group and the document count of that group.
(date) histogram
A multi-bucket values source based aggregation that can be applied on numeric values or numeric range values extracted from the documents. It dynamically builds fixed size (a.k.a. interval) buckets over the values.
Top Hits
A top_hits metric aggregator keeps track of the most relevant document being aggregated. This aggregator is intended to be used as a sub aggregator, so that the top matching documents can be aggregated per bucket.
distinct on field
Counts the amount of different values on the selected field.