Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Bucket Sub Aggregations and Top Hits #19096

Closed
csepulv opened this issue May 15, 2018 · 5 comments
Closed

Custom Bucket Sub Aggregations and Top Hits #19096

csepulv opened this issue May 15, 2018 · 5 comments
Labels
[Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation enhancement New value added to drive a business result

Comments

@csepulv
Copy link

csepulv commented May 15, 2018

I would like to a custom aggregation that either doesn't use geohash'ing or uses geohash as a sub-aggregation.

Imagine you are mapping schools or fast food restaurants. I'd like to aggregate by the school type (elementary, middle school, etc.) or restaurant chain name first, then map the metric of count, average, etc. In this case geohash, as a sub aggregation, is fine. (Basically, I have some term/identifier I'd like to use as first level aggregation.)

But I would also like to show the first or last school/restaurant opening, in which case I'd like a top_hits sub-aggregation and not use the geohash (or, in some cases use top_hits with the geohash).

To be more specific, if I have a position geopoint, the resulting aggregation the exising map visualization gets is:

"aggs": {
              "2": {
                "geohash_grid": {
                  "field": "position",
                  "precision": 3
                },
                "aggs": {
                  "3": {
                    "geo_centroid": {
                      "field": "position"
                    }
                  }
                }
              }
            }

But assume I want a breakdown by brand (as in my earlier noted example), I would like the following aggregation/buckets:

"aggs": {
          "brand": {
            "terms": {
              "field": "brand_name"
            },
            "aggs": {
              "2": {
                "geohash_grid": {
                  "field": "position",
                  "precision": 3
                },
                "aggs": {
                  "3": {
                    "geo_centroid": {
                      "field": "position"
                    }
                  }
                }
              }
            }
          }
        }

I'd like more control over the aggregations and sub aggregations.

Thanks

@w33ble w33ble added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) triage_needed labels May 15, 2018
@timroes
Copy link
Contributor

timroes commented May 16, 2018

Is it correct, that you are talking about configuration options for the region or coordinate/tile map?

@csepulv
Copy link
Author

csepulv commented May 16, 2018

Coordinate Map

@timroes timroes added [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation and removed Feature:Visualizations Generic visualization features (in case no more specific feature label is available) labels May 16, 2018
@thomasneirynck thomasneirynck added enhancement New value added to drive a business result and removed triage_needed labels May 23, 2018
@nreese
Copy link
Contributor

nreese commented Feb 24, 2020

@csepulv

Top hits has been implemented in Maps application, https://www.elastic.co/guide/en/kibana/current/maps-top-hits-aggregation.html, and produces requests like

"aggs": {
    "entitySplit": {
      "terms": {
        "size": 10000,
        "shard_size": 10000,
        "field": "machine.os.keyword"
      },
      "aggs": {
        "entityHits": {
          "top_hits": {
            "size": 1,
            "script_fields": {},
            "docvalue_fields": [
              "geo.coordinates"
            ],
            "_source": false
          }
        }
      }
    }

For you other request about nesting geotile_grid aggregation under terms aggregation, this will produce problems with hitting cluster setting search.max_buckets.

There is an open PR that implements the inverse of this, which is finding the top term per geotile_grid. Would a solution like this work for your use case?

@csepulv
Copy link
Author

csepulv commented Feb 24, 2020

It is good to hear that Maps has added top hits. (Thanks)

I think the PR you mentioned might work for the use case I noted. I am not sure, as we had to move away from the Kibana map plugin.

It might make sense to close this issue at this point.

@nreese
Copy link
Contributor

nreese commented Feb 24, 2020

closed by:
top hits: #38052
top term: #57875

@nreese nreese closed this as completed Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation enhancement New value added to drive a business result
Projects
None yet
Development

No branches or pull requests

5 participants