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

Feature fix 99239 #99482

Closed
wants to merge 1 commit into from
Closed

Feature fix 99239 #99482

wants to merge 1 commit into from

Conversation

maihde
Copy link
Contributor

@maihde maihde commented May 6, 2021

Summary

This PR provides a proof-of-concept fix for #99239. It likely needs iteration before being merged into the baseline. It makes the following usability improvements:

  • Only include geo-fields that are actually being used in layers. This may be a debatable point (i.e. I want to render fieldA but filter on fieldB) when drawing shapes; if that is a desired feature, then I suggest that the "Filtering field" list be ordered such that those other fields are lower on the list and in a visually distinct manner.
  • When multiple index patterns have the same field name, it's redundant to show each of them in the list because the ultimate filter that is created is agnostic to the index. Instead, the control now shows the geoFieldType and deduplicates based off name/type.

image

This PR was developed against v7.11.2.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@maihde maihde requested review from a team as code owners May 6, 2021 15:08
@kibanamachine
Copy link
Contributor

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@jbudz
Copy link
Member

jbudz commented May 6, 2021

@maihde Hi! Thanks for the PR. Is this supposed to be targeting a different branch? The diff looks quite large.

@maihde
Copy link
Contributor Author

maihde commented May 6, 2021 via email

@jbudz jbudz changed the base branch from master to 7.11 May 6, 2021 17:08
@jbudz jbudz added the [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation label May 6, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

@jbudz
Copy link
Member

jbudz commented May 6, 2021

I updated the target branch and tagged this with the geo team for review. Thanks again.

@lukeelmers lukeelmers requested review from a team and removed request for a team May 6, 2021 19:06
@thomasneirynck
Copy link
Contributor

hi @maihde , thx for the proposal. Overall, I think these changes make sense to me.

The first thing that jumps out is logistical really. This PR targets 7.11. Could you open this PR up against master instead? After a PR is merged into master, it will then get backported to the 7.x release branch.

Let me know if you have questions or comments around this.

@thomasneirynck thomasneirynck added the enhancement New value added to drive a business result label May 10, 2021
@thomasneirynck thomasneirynck self-requested a review May 10, 2021 15:02
@thomasneirynck thomasneirynck added release_note:enhancement and removed enhancement New value added to drive a business result labels May 10, 2021
@maihde
Copy link
Contributor Author

maihde commented May 18, 2021

@thomasneirynck I have updated the PR to target the master branch.

@maihde maihde changed the base branch from 7.11 to master May 18, 2021 18:48
@kmartastic
Copy link
Contributor

Hey @maihde.

We had a discussion (@thomasneirynck @nreese @nickpeihl) about interactive spatial filtering and how we might want to improve it today. I'll summarize my perspective here.

I think the most common way to use a spatial filter is to filter everything that is visible. If you draw a circle, and there are 3 layers intersecting/within the circle, each layer should be filtered.

I think the second most common filtering is to apply the filter to a specific layer -- but -- do not apply the filter to all other layers. You can do this today, but you need to set all other layers to ignore global filters.

The least common scenario to me is the default behavior today -- you specify a layer in the map field, and draw a filter, which only applies to the layers based off the field/index pattern.

Although I agree your proposal is reasonable. It's not really the direction I want to invest in. I would rather change (break) the default behavior and adapt it to my preferences above. I wouldn't want to do anything, without broader customer feedback (which I will try to gather).

What do you think?

@maihde
Copy link
Contributor Author

maihde commented May 26, 2021

@kmartastic yes, I agree with your perspective. In our case, the most common and least common scenarios generally overlap because all of the layers are using the same geo-spatial field. This PR attempts to address a narrow issue quickly with minimal change rather than the broader usability concerns. If you think there is a timely path toward improving things more broadly we are happy to test things out.

@nreese
Copy link
Contributor

nreese commented May 26, 2021

If you think there is a timely path toward improving things more broadly we are happy to test things out.

@maihde The ability to generate a filter that will work for any geo field on the map was needed for filtering dashboard panels by map bounds. From experimenting with this PR, we found that we can generated a bool.should filter that contains nested bool.must filters that test to ensure the geoField exists prior to testing if the geoField is contained in the spatial feature. In the example below, the filter looks for documents where either geoFieldAlpha exists and is within the bounding box or geoFieldBravo exists and is within the bounding box allowing this filter to match documents with either geo field regardless of if the other geo field exists or not.

{
  query: {
    bool: {
      should: [
        {
          bool: {
            must: [
              {
                exists: {
                  field: 'geoFieldAlpha',
                },
              },
              {
                geo_bounding_box: {
                  [geoFieldAlpha]: {
                    top_left: [120, 60],
                    bottom_right: [140, 40],
                  },
                },
              },
            ],
          },
        },
        {
          bool: {
            must: [
              {
                exists: {
                  field: 'geoFieldBravo',
                },
              },
              {
                geo_bounding_box: {
                  [geoFieldBravo]: {
                    top_left: [120, 60],
                    bottom_right: [140, 40],
                  },
                },
              },
            ],
          },
        },
      ]
    },
  }

This method was not really possible in prior releases because the query syntax were so different between geo_point and geo_shape (with geo_point query constructs and geo_shape query constructs not supporting the other's geo field type). Elasticsearch has really helped out by supporting both geo_shape and geo_point fields for most geospatial queries now, making this effort much easier.

We should be able to use this patter when creating spatial filters and all creating a spatial filter for all geo fields in the map.

@nreese
Copy link
Contributor

nreese commented May 26, 2021

@maihde

I have created #100735 to remove the need to select a geo field when creating a spatial filter. The generated filter is a bool.should filter that contains nested bool.must filters that test to ensure each geoField exists prior to testing if the geoField is contained in the spatial feature. That way, the filter will work for each index and geo field in the map.

Let me know if this functionality works for your use cases.

@thomasneirynck
Copy link
Contributor

Replaced by #99482. Thanks @maihde for creating this POC and getting the ball rolling!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants