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

SavedObjects search_dsl: add match_phrase_prefix clauses when using prefix search #82693

Merged

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Nov 5, 2020

Summary

Fix #5734 Fix #20242

See #5734 (comment) for more context about the implementation design.

  • Adapt getQueryParams to add per-field match_phrase_prefix clauses when the user is performing a prefix search (* wildcard at the end of the query)
  • cleanup getQueryParams to no longer relies on mapping, and uses the SO type registry as single source of truth regarding declared types

Checklist

Release notes

Fix a bug causing searching for saved objects using special characters such as * or - to not return any results.

@pgayvallet pgayvallet changed the title add match_phrase_prefix clauses when using prefix search SavedObjects search_dsl: add match_phrase_prefix clauses when using prefix search Nov 5, 2020
@pgayvallet pgayvallet marked this pull request as ready for review November 5, 2020 13:10
@pgayvallet pgayvallet requested a review from a team as a code owner November 5, 2020 13:10
@pgayvallet pgayvallet added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Nov 5, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

Copy link
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

Left a question, but otherwise lgtm

Comment on lines +287 to +296
return mppFields.map(({ field, boost }) => {
return {
match_phrase_prefix: {
[field]: {
query,
boost,
},
},
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't really know how this API works, but does it matter that we're creating a query like:

"should": [
        {
          "simple_query_string": {
            "query": "my-vis*",
            "fields": [
              "visualization.title",
              "visualization.description"
            ],
            "default_operator": "OR"
          }
        },
        {
          "match_phrase_prefix": {
            "visualization.title": {
              "query": "my-vis",
              "boost": 1
            }
          }
        },
        {
          "match_phrase_prefix": {
            "visualization.description": {
              "query": "my-vis",
              "boost": 1
            }
          }
        }
]

I was expecting it to be:

"should": [
        {
          "simple_query_string": {
            "query": "my-vis*",
            "fields": [
              "visualization.title",
              "visualization.description"
            ],
            "default_operator": "OR"
          }
        },
        {
          "match_phrase_prefix": {
            "visualization.title": {
              "query": "my-vis",
              "boost": 1
            },
            "visualization.description": {
              "query": "my-vis",
              "boost": 1
            }
          }
        }
]

Copy link
Contributor Author

@pgayvallet pgayvallet Nov 6, 2020

Choose a reason for hiding this comment

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

I also was tbh. But match_phrase prefix does not work that way unfortunately (and even if it was, I would expect your syntax to be a AND condition between the fields, where we want a OR). That can creates a lot of clauses in the bool query, but when I discussed it with the ES teams, they told me it should not impact performances in any significative way.

@rudolf
Copy link
Contributor

rudolf commented Nov 6, 2020

cleanup getQueryParams to no longer relies on mapping, and uses the SO type registry as single source of truth regarding declared types

❤️

@pgayvallet pgayvallet merged commit fdc1839 into elastic:master Nov 9, 2020
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Nov 9, 2020
…refix search (elastic#82693)

* add match_phrase_prefix clauses when using prefix search

* add FTR tests
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Nov 9, 2020
…refix search (elastic#82693)

* add match_phrase_prefix clauses when using prefix search

* add FTR tests
# Conflicts:
#	src/core/server/saved_objects/service/lib/search_dsl/query_params.test.ts
#	src/core/server/saved_objects/service/lib/search_dsl/query_params.ts
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

pgayvallet added a commit that referenced this pull request Nov 9, 2020
…refix search (#82693) (#82933)

* add match_phrase_prefix clauses when using prefix search

* add FTR tests
pgayvallet added a commit that referenced this pull request Nov 9, 2020
…using prefix search (#82693) (#82935)

* SavedObjects search_dsl: add match_phrase_prefix clauses when using prefix search (#82693)

* add match_phrase_prefix clauses when using prefix search

* add FTR tests
# Conflicts:
#	src/core/server/saved_objects/service/lib/search_dsl/query_params.test.ts
#	src/core/server/saved_objects/service/lib/search_dsl/query_params.ts

* fix test file due to merge

* fix files again
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 9, 2020
* master:
  Added `defaultActionMessage` to index threshold alert UI type definition (elastic#80936)
  [ILM] Migrate Delete phase and name field to Form Lib (elastic#82834)
  skip flaky suite (elastic#57426)
  [Alerting] adds an Run When field in the alert flyout to assign the action to an Action Group (elastic#82472)
  [APM] Expose APM event client as part of plugin contract (elastic#82724)
  [Logs UI] Fix errors during navigation (elastic#78319)
  Enable send to background in TSVB (elastic#82835)
  SavedObjects search_dsl: add match_phrase_prefix clauses when using prefix search (elastic#82693)
  [Ingest Manager] Unify install* under installPackage (elastic#82916)
phillipb added a commit to phillipb/kibana that referenced this pull request Nov 10, 2020
…e-details-overlay

* 'master' of github.com:elastic/kibana: (201 commits)
  Added `defaultActionMessage` to index threshold alert UI type definition (elastic#80936)
  [ILM] Migrate Delete phase and name field to Form Lib (elastic#82834)
  skip flaky suite (elastic#57426)
  [Alerting] adds an Run When field in the alert flyout to assign the action to an Action Group (elastic#82472)
  [APM] Expose APM event client as part of plugin contract (elastic#82724)
  [Logs UI] Fix errors during navigation (elastic#78319)
  Enable send to background in TSVB (elastic#82835)
  SavedObjects search_dsl: add match_phrase_prefix clauses when using prefix search (elastic#82693)
  [Ingest Manager] Unify install* under installPackage (elastic#82916)
  [Fleet] Make stream id unique in agent policy (elastic#82447)
  skip flaky suite (elastic#82915)
  skip flaky suite (elastic#75794)
  Copy `dateAsStringRt` to observability plugin (elastic#82839)
  [Maps] rename connected_components/map folder to mb_map (elastic#82897)
  [Security Solution] Fix EventsViewer DnD cypress tests (elastic#82619)
  [Security Solution] Adds logging and performance fan out API for threat/Indicator matching (elastic#82546)
  Implemented Alerting health status pusher by using task manager and status pooler for Kibana status plugins 'kibanahost/api/status' (elastic#79056)
  [APM] Adds new configuration 'xpack.apm.maxServiceEnvironments' (elastic#82090)
  Move single use function in line (elastic#82885)
  [ML] Add unsigned_long support to data frame analytics and anomaly detection (elastic#82636)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Saved Objects release_note:enhancement Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.10.1 v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can't use * in saved object searches Searching for saved objects with dashes shows no results
4 participants