{% extends "docs/docs_base.html" %} {% block doc_title %}Super Search Examples{% endblock %} {% block doc_content %}
Get the top 20 signatures for {{ product_name }} {{ version }}.
{{ full_url(request, "api:model_wrapper", model_name="SuperSearch") }}?{{ make_query_string(product=product_name, version=version, _facets="signature", _facets_size=20) }}
The _facets_size parameter allows you to set the number of
results in all aggregations. Setting too big a number will of course make
the request take longer. Note that there are no ways of paginating over
results of an aggregation.
Get the first 100 crash reports for {{ product_name }} between {{ three_days_ago.strftime("%B %d, %Y") }} and {{ yesterday.strftime("%B %d, %Y") }}.
=" + three_days_ago.isoformat(), "<" + yesterday.isoformat()]) }}">{{ full_url(request, "api:model_wrapper", model_name="SuperSearch") }}?{{ make_query_string(product=product_name, date=[">=" + three_days_ago.isoformat(), "<" + yesterday.isoformat()]) }}
We are passing dates here, as opposed to datetimes. They will automatically be transformed into datetimes with hour, minute, second and milisecond set to 0 and a UTC timezone.
We did not specify _results_number so we will get 100 results
as that is the default value.
We did not specify _columns so each result will have the
default set of keys, namely uuid, date,
signature, product and version.
Get the first 600 crash reports for release channel.
{{ full_url(request, "api:model_wrapper", model_name="SuperSearch") }}?{{ make_query_string(release_channel="release", _results_number=200, _results_offset=0) }}{{ full_url(request, "api:model_wrapper", model_name="SuperSearch") }}?{{ make_query_string(release_channel="release", _results_number=200, _results_offset=200) }}{{ full_url(request, "api:model_wrapper", model_name="SuperSearch") }}?{{ make_query_string(release_channel="release", _results_number=200, _results_offset=400) }}
It's a bad idea to try to get too many results at once. It will make
Elasticsearch slower to respond, and will generate a big response for our
web servers to return. That can quite easily lead to timeouts. Instead, it
is much more efficient to make several small requests, and to then combine
their results. This is what we do here, by incrementing
_results_offset of the value of _results_number
in every request.
Note that Elasticsearch caches the results of filters, so all requests
following the first one should be a lot faster. However, since the
date parameter has default values based on the current time,
it might be a good idea to give it a value, in order to fully use the
caching mechanism. For example, add &date=<{{ today }}
to all your URLs.
Count the number of different installations for each version of a product.
{{ full_url(request, "api:model_wrapper", model_name="SuperSearch") }}?{{ make_query_string(**{"product": product_name, "_aggs.product.version": "_cardinality.install_time"}) }}
To count the number of different installations, we count the number of distinct install times. Since it is unlikely that two software have been installed at the exact same time, it gives us a good estimate.
It is possible to use special aggregations as parameters of an aggregation, like here we use a "cardinality" aggregation inside a nested aggregation. This query will perform an aggregation on products, and for each product it will aggregate on versions, and for each version it will count the distinct number of install times.
Find signatures that start with OOM | and have at least
another pipe (|).
{{ full_url(request, "api:model_wrapper", model_name="SuperSearch") }}?{{ make_query_string(signature="@\"OOM | \".*\" | \".*", _facets="signature", _results_number=0) }}
The syntax you can use to write your regexes is described in the Elasticsearch documentation.