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

[Autocomplete] Support useTimeFilter option #81515

Merged
merged 23 commits into from
Nov 10, 2020

Conversation

lizozom
Copy link
Contributor

@lizozom lizozom commented Oct 22, 2020

Summary

Temporarily patches #46054
Related to #15887

This PR applies the active timefilter onto the autocomplete requests, following a request from the Elasticsearch team, to fix the problem mentioned in #46054.

This solution is temporary, as Elasticsearch plans to introduce a new and more efficient autocomplete API. Open question: Will the new ES API use the entire timerange? Or will it be also limited to the timerange?

While this approach reduces the time needed to return autocomplete results for shorter time ranges, when the time range is long or if an index is not time based, it approaches the same performance of the current behavior on master.

It's worth mentioning here, that even on master frozen indices are not being queried for autocomplete suggestions.

Changes with this approach

Unavailable results

On master, autocomplete results are constructed from the entire time range. In this branch only a subset of the results is returned to the user. This is emphasized by the fact that the current UI\UX, doesn't allow the user to see the current time range, while editing the query.

If an organization is unhappy with this behavior they can turn off the autocomplete:useTimerange advanced setting to revert to the previous behavior.

master
Discover - Elastic (2)

New behavior
Discover - Elastic (5)

Inconsistent results between components \ solutions

After much deliberation with @elastic-jb , we decided to keep the drop-downs in the FilterBar populated with the full list of results (i.e. not filter by time) while the Query autocomplete suggestions will be filtered. So a user might see different suggestions in both places.

query-bar-filter-bar-conflict

Relative time range memoization

Relative time ranges will be rounded to the nearest minute, in order to avoid memoization issues.

Impact on other solutions

The autocomplete suggestions API is used by multiple consumers:

  • APM
  • Beats
  • Infra
  • Ingest
  • Uptime
  • Maps

I think it's worth hearing their opinions about this change as well, and whether it has any implications on the solutions.

Release Notes

This PR applies the active timefilter onto the autocomplete requests, to fix performance issues mentioned in #46054. This behavior will be enabled by default, but can be turned off by disabling the autocomplete:useTimerange advanced settings.

This solution is temporary, as Elasticsearch plans to introduce a new and more efficient autocomplete API.

@lizozom lizozom self-assigned this Oct 22, 2020

function resolver(title: string, field: IFieldType, query: string, boolFilter: any) {
function resolver(title: string, field: IFieldType, query: string, filters: any[]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be filters: Filter[] in this whole file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not filters of type Filter, but an array of whatever type BoolQuery.filter is ( src/plugins/data/server/search/es_search/elasticsearch.ts).

We could fix that, but I wouldn't want to do it in this PR.

@timroes timroes added v7.11.0 and removed v7.11 labels Oct 30, 2020
@kobelb
Copy link
Contributor

kobelb commented Oct 30, 2020

I think it's reasonable for us to add an option for the time filter to be applied to the autocomplete suggestions. However, if we've been ignoring the time filter for autocomplete for the entirety of 7.x, or since its implementation mid 7.x, changing this behavior is a breaking change. Is my understanding correct that we've had enough users experience issues with the performance/health of their ES clusters that we should make this breaking change in a minor?

@lizozom, I really like the detailed analysis that you performed in #46054 (comment). Is my understanding correct that without these changes, we're in the "TERMS w/totals, wo/timerange, wo/sort" column? Is there a column that represents the performance with only these changes? I don't think it's absolutely pertinent for us to benchmark this if we have the expert guidance from the ES team, I'm primarily asking out of curiosity.

@lizozom
Copy link
Contributor Author

lizozom commented Oct 30, 2020

@kobelb the nearest benchmark would be the second column. Adding sorting didn't improve the results much.
I should mention that these benchmarks were done without terminateAfter, to avoid a cut off.

Since this is a serious problem, I guess fixing it in a minor would make sense, but I do think we need to at least find a way to resolve the inconsistencies I mentioned above as well as the memoization problem.

@stacey-gammon
Copy link
Contributor

stacey-gammon commented Nov 3, 2020

Thanks so much for being so explicit with the corner cases of this approach Liza! @elastic-jb - do you know what the original reason was for removing the time filter from auto complete results? I hope we aren't repeating history, if there were legit reasons to remove it.

I think there are two ways people use autocomplete. One is for fast type-ahead. I start typing, I see what I want, I click it or press tab. The other reason I personally use type ahead is for searching. For example, I'm in Discover and I have an issues-* index. I want to filter on issues created by a certain person but I can't quite remember their name. I just know it started with a J. This issue was created awhile ago, because this person doesn't work at Elastic anymore. I start to type my query hoping that auto complete will provide me with the rest of their name, because it's one of those "I'll know it when I see it". I type author: j. If my time filter happens to be too short, I won't see their name. I don't think "oh I don't see their name because the issue they created isn't in my time range", instead I think something is broken. My first thought was to filter - I don't even know what the time range is. That will be my second thought if no results show up. "Oh, I don't see anything here, let me expand the time range"

I wouldn't expect the results to be filtered by time range and I would think something is broken. If we want to filter by time range to optimize for the fast typeahead use case, I think that's okay, but I think ideally it will be made clear in the UI. Like "results limited to time x - y".

Also to the point about:

. This is emphasized by the fact that the current UI\UX, doesn't allow the user to see the current time range, while editing the query.

💯 I literally was just trying this out and thought my index pattern didn't have a time range and was confused why I wasn't seeing any results. I didn't realize it was limited to last 15 minutes.

Update autocomplete tests and docs
@lizozom
Copy link
Contributor Author

lizozom commented Nov 4, 2020

Copying here the original PR text, as I update it with the chosen solutions:

Potential issues with this approach

Unavailable results

On master, autocomplete results are constructed from the entire time range. In this branch only a subset of the results is returned to the user. This is emphasized by the fact that the current UI\UX, doesn't allow the user to see the current time range, while editing the query.

master
Discover - Elastic (2)

New behavior
Discover - Elastic (5)

Inconsistent results between various screens

This may occur under a few different cases, with similar effects:

  • If there are two index patterns for the same index - one without a time field.
  • When switching from Discover to the Context (single document) view
  • When using autocomplete from the query bar vs. from the filter bar vs. from a custom field selector.

For example, if we restrict the QueryBar input with the time range, but choose to have all suggestions available in the FilterBar, the user will see different suggestions in both.

query-bar-filter-bar-conflict

Alternatively, if we choose to apply the time range filtering to both the QueryBar and FilterBar, we would still see different results in the Context view in Discover, as it doesn't use the time range at all.

discover-context-conflict

Relative time range memoization

On master autocomplete results are always memoized. On this branch relative time ranges or any time range that includes now, are not memoized.

master
Discover - Elastic (4)

New behavior
Discover - Elastic (3)

@shahzad31
Copy link
Contributor

uptime already does this by passing bool , range filter https://github.com/elastic/kibana/blob/master/x-pack/plugins/uptime/public/components/overview/kuery_bar/kuery_bar.tsx#L108

useTimeFilter in uptime
@lizozom
Copy link
Contributor Author

lizozom commented Nov 5, 2020

@lizozom lizozom marked this pull request as ready for review November 5, 2020 14:50
@shahzad31
Copy link
Contributor

Code looks good to me for uptime, just need to verify functionality in uptime perhaps @Kerry350 or @andrewvc can do it whilst i am on PTO.

@Kerry350 Kerry350 self-requested a review November 6, 2020 13:30
@lizozom lizozom requested a review from lukasolson November 6, 2020 16:46
@lizozom
Copy link
Contributor Author

lizozom commented Nov 9, 2020

@elasticmachine merge upstream

@stacey-gammon stacey-gammon removed their request for review November 9, 2020 15:38
src/plugins/data/common/constants.ts Outdated Show resolved Hide resolved
Co-authored-by: Lukas Olson <olson.lukas@gmail.com>
@lizozom
Copy link
Contributor Author

lizozom commented Nov 10, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 3.1MB 3.1MB -195.0B
data 235.0KB 235.0KB +19.0B
uptime 983.1KB 983.0KB -140.0B
total -316.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 963.2KB 964.2KB +1.0KB
dataEnhanced 28.3KB 28.3KB +52.0B
total +1.1KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@lizozom lizozom merged commit 8842e9b into elastic:master Nov 10, 2020
lizozom added a commit to lizozom/kibana that referenced this pull request Nov 10, 2020
* pass timefilter to autocomplete

* ignoreTimeRange advanced setting

* Show all results in filter bar autocomplete

* Round timerange to minute for autocomplete memoization

* Change useTimeFilter param name
Update autocomplete tests and docs

* Fix maps test
useTimeFilter in uptime

* docs

* useTimeRange in apm

* remove date validation

* Update src/plugins/data/common/constants.ts

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

* docs

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Lukas Olson <olson.lukas@gmail.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 12, 2020
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

1 similar comment
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 15, 2020
lizozom added a commit that referenced this pull request Nov 15, 2020
* pass timefilter to autocomplete

* ignoreTimeRange advanced setting

* Show all results in filter bar autocomplete

* Round timerange to minute for autocomplete memoization

* Change useTimeFilter param name
Update autocomplete tests and docs

* Fix maps test
useTimeFilter in uptime

* docs

* useTimeRange in apm

* remove date validation

* Update src/plugins/data/common/constants.ts

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

* docs

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Lukas Olson <olson.lukas@gmail.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Lukas Olson <olson.lukas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement Team:APM - DEPRECATED Use Team:obs-ux-infra_services. Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.