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

If 'ignoreFilterIfFieldNotInIndex' set to 'true', global time filter is not working in Discover. #21358

Closed
prabhakarmanthena opened this issue Jul 27, 2018 · 3 comments
Labels
bug Fixes for quality problems that affect the customer experience

Comments

@prabhakarmanthena
Copy link

prabhakarmanthena commented Jul 27, 2018

Kibana version: 6.3.0

Elasticsearch version:6.3.0

Description:
If we enable the "ignoreFilterIfFieldNotInIndex" in advanced settings. I observed the global time filter is not applied in the discover page.
In my opinion below thing is causing this issue.
in src\ui\public\courier\data_source\search_source.js

 this._filterPredicates = [
        (filter) => {
          // remove null/undefined filters
          return filter;
        },
        (filter) => {
          const disabled = _.get(filter, 'meta.disabled');
          return disabled === undefined || disabled === false;
        },
        (filter, state) => {
          if (!config.get('courier:ignoreFilterIfFieldNotInIndex')) {
            return true;
          }

          if ('meta' in filter && 'index' in state) {
            const field = state.index.fields.byName[filter.meta.key];
            if (!field) return false;
          }
          return true;
        }
      ];

filter.meta.key is undefined. and I didn't see filter.meta.key value defined in src\ui\public\timefilter\timefilter.js

 let filter;
      const timefield = indexPattern.timeFieldName && _.find(indexPattern.fields, { name: indexPattern.timeFieldName });

      if (timefield) {
        const bounds = timeRange ? this.calculateBounds(timeRange) : this.getBounds();
        filter = { range: {} };
        filter.range[timefield.name] = {
          gte: bounds.min.valueOf(),
          lte: bounds.max.valueOf(),
          format: 'epoch_millis'
        };
      } 

Or in src\ui\public\courier\data_source\_root_search_source.js.

 globalSource.filter(function (globalSource) {
    // dynamic time filter will be called in the _flatten phase of things
    const filter = timefilter.get(globalSource.get('index'));
    // Attach a meta property to it, that we check inside visualizations
    // to remove that timefilter again because we use our explicitly passed in one.
    // This should be removed as soon as we got rid of inheritance in SearchSource
    // across the boundary or visualization.
    if (filter) {
      filter.meta = { _globalTimefilter: true };
    }
    return filter;
  });

Seems need to define a filter.meta.key value in timefilter.js to fix this issue.

Steps to reproduce:

  1. Go to advanced settings and set 'ignoreFilterIfFieldNotInIndex' to 'true'
  2. Go to discover page try to change the time filter values

Expected behavior: Irrespective of this setting global time filter should work

Screenshots (if relevant):
image
cc: @timroes

@Bargs Bargs added bug Fixes for quality problems that affect the customer experience :Discovery labels Jul 31, 2018
@Bargs
Copy link
Contributor

Bargs commented Aug 2, 2018

@timroes I think this is probably a side effect of #19221. Previously the time filter would have failed this conditional but now that it has a meta prop it will pass and subsequently fail to find a field because there is no meta.key. What's funny is, I can reproduce the issue in 6.3, but not master. Are you aware of any related changes going into master but not 6.3 that might have fixed this?

@Bargs
Copy link
Contributor

Bargs commented Aug 2, 2018

For some users this is making Discover totally lock up #21398

@Bargs
Copy link
Contributor

Bargs commented Aug 10, 2018

I checked our 6.4 and 6.x branches and this bug is fixed in those versions as well. I believe this is the PR that probably fixed it: #19172. The meta key was being added to the time filter object in _root_search_source, which was deleted in this PR. Since this is already fixed in 6.4+ I'm going to close this ticket.

@Bargs Bargs closed this as completed Aug 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience
Projects
None yet
Development

No branches or pull requests

2 participants