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

Choose a source dialog box returns unexpected results when searching data views with colon #184496

Closed
eedugon opened this issue May 30, 2024 · 5 comments · Fixed by #190464
Closed
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)

Comments

@eedugon
Copy link

eedugon commented May 30, 2024

Kibana version:
8.13.2

When searching in the "choose a source" dialog box for data views with colon (:) in their names, the search results are unexpected. The workaround consists of using double quotes.

Colons in data views names are very common when using Cross Cluster Search (CCS).

Steps to reproduce:
0. Ensure that you have in your system a data view pointing to a remote cluster (in my lab it's called remote:test-index).

  1. Open Visualizations Library
  2. Click on Create New Visualization
  3. Select Aggregations based --> Vertical bar
  4. In the "Choose a source" dialog type the data view you want to search, which includes a colon : character. You will see that after typing one letter after the colon the search results don't make sense.

Example:
Stage 0, nothing written in search box, all looks ok:
stage-0

We want to search for that remote:test-index pattern.... so if we write remote or remote: all works fine:

stage-1

But as soon as we add one extra letter remote:t then the search results get broken (everything is returned apparently):

stage-2

^^ The previous results are unexpected, maybe because the search term is divided in tokens?

** Workaround **
Using double quotes the problem disappears:
stage-3-workaround

@eedugon eedugon added bug Fixes for quality problems that affect the customer experience Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) labels May 30, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@tsullivan
Copy link
Member

tsullivan commented Jun 5, 2024

I have reproduced this problem in the global search bar as well.

I added a console.log statement here:

diff --git x-pack/plugins/saved_objects_tagging/public/ui_api/parse_search_query.ts x-pack/plugins/saved_objects_tagging/public/ui_api/parse_search_query.ts
index 625c7709417..80ab5152ed3 100644
--- x-pack/plugins/saved_objects_tagging/public/ui_api/parse_search_query.ts
+++ x-pack/plugins/saved_objects_tagging/public/ui_api/parse_search_query.ts
@@ -30,6 +30,7 @@ export const buildParseSearchQuery = ({
 
     try {
       parsed = Query.parse(query);
+      console.log('searchQuery-buildParseSearch-parsed', parsed);
     } catch (e) {
       return {
         searchTerm: query,

What I learned: when you write "remote:test-index" in a search box in Kibana, it gets parsed into an AST with the clause:

  • field "remote" must eq value "test-index"

Screenshot of output of logs to the console which I have added in my investigation:
image

I think the only "field" we care about in the saved object search dialog boxes is the tag filter, which would let you narrow down the results that are tagged with "foo" by filtering for tag:(foo). Note that the parenthesis around the value make the parser interpret the value as an array:

image

I will reach out to some teams outside of AppEx-SharedUX for help:
cc @elastic/kibana-core, original authors of the saved objects tagging features
cc @elastic/eui-team, maintainers of the query parser

@TinaHeiligers
Copy link
Contributor

Thanks for the ping!
The issue is very similar to one we had a while ago with KQL and kuery, where the text from the search bar is passed directly through to the underlying AST. In the KQL/kuery case, we had some control over the AST and could modify that. Here we don’t.
We'd need to implement a “query interpreter” that transforms the input into something the AST will interpret correctly.
Using double quotes around a name that contains a colon works because it escapes the AST grammar for indicating key/value pairs. What you’re looking for is a similar escape mechanism.

Ideally, someone familiar with EUI's AST should suggest a workaround. In the mean time, we can try to implement custom middleware.

@pgayvallet
Copy link
Contributor

IIRC, EUI's query language escape sequence is just the double quote character.

So searching for "remote:test" instead of remote:test may do the trick

@tsullivan
Copy link
Member

I'm working on this through our EUI repo, which is where the query parser lives: elastic/eui#7960

kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Sep 19, 2024
…cify recognized fields (elastic#190464)

This PR adds a new option to the `SchemaType` interface for parsing a
query from a search in EuiSearchBar. This new field controls how
EuiSearchBar text is parsed into a Query object. It enables better
accuracy in how search terms are parsed when they include a `:`
character.

## Release note
Fixed an issue when using search bars with a term that includes a colon
`:` character.

## Summary

Closes elastic#184496
Depends on elastic/eui#7960

**GLOBAL SEARCH: BEFORE**

![akshfgkalsfh-before](https://github.com/user-attachments/assets/22377a3e-394e-43fb-83db-ae2477ce22d7)

**GLOBAL SEARCH: AFTER**

![akshfgkalsfh-after](https://github.com/user-attachments/assets/406d56eb-c946-493b-94f3-abb0380611f3)

**SAVED OBJECTS MANAGEMENT: BEFORE**

![okjoyofjiuh-before](https://github.com/user-attachments/assets/c1c56572-31aa-41df-b0c5-3eef421a06c5)

**SAVED OBJECTS MANAGEMENT: AFTER**

![okjoyofjiuh-after](https://github.com/user-attachments/assets/9e19bbcf-72e7-43d5-a9e7-3c5805632a38)

**SAVED OBJECTS FINDER: BEFORE**

![lfdgnhklfd-before](https://github.com/user-attachments/assets/b826987d-8af6-4c20-93b0-0d0bb76d9501)

**SAVED OBJECTS FINDER: AFTER**

![lfdgnhklfd-after](https://github.com/user-attachments/assets/e8e007b9-91f7-4209-bfd5-ce43a2cbc894)

## Checklist
 - [x] Ensure that filtering using `type:` and `tags:` still works

(cherry picked from commit 460ca2a)
kibanamachine referenced this issue Sep 19, 2024
…to specify recognized fields (#190464) (#193448)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Global Search, Saved Objects Management] Use new parse option to
specify recognized fields
(#190464)](#190464)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Tim
Sullivan","email":"tsullivan@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-19T16:02:45Z","message":"[Global
Search, Saved Objects Management] Use new parse option to specify
recognized fields (#190464)\n\nThis PR adds a new option to the
`SchemaType` interface for parsing a\r\nquery from a search in
EuiSearchBar. This new field controls how\r\nEuiSearchBar text is parsed
into a Query object. It enables better\r\naccuracy in how search terms
are parsed when they include a `:`\r\ncharacter.\r\n\r\n## Release
note\r\nFixed an issue when using search bars with a term that includes
a colon\r\n`:` character.\r\n\r\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/184496\r\nDepends on
https://github.com/elastic/eui/pull/7960\r\n\r\n**GLOBAL SEARCH:
BEFORE**\r\n\r\n![akshfgkalsfh-before](https://github.com/user-attachments/assets/22377a3e-394e-43fb-83db-ae2477ce22d7)\r\n\r\n**GLOBAL
SEARCH:
AFTER**\r\n\r\n![akshfgkalsfh-after](https://github.com/user-attachments/assets/406d56eb-c946-493b-94f3-abb0380611f3)\r\n\r\n**SAVED
OBJECTS MANAGEMENT:
BEFORE**\r\n\r\n![okjoyofjiuh-before](https://github.com/user-attachments/assets/c1c56572-31aa-41df-b0c5-3eef421a06c5)\r\n\r\n**SAVED
OBJECTS MANAGEMENT:
AFTER**\r\n\r\n![okjoyofjiuh-after](https://github.com/user-attachments/assets/9e19bbcf-72e7-43d5-a9e7-3c5805632a38)\r\n\r\n**SAVED
OBJECTS FINDER:
BEFORE**\r\n\r\n![lfdgnhklfd-before](https://github.com/user-attachments/assets/b826987d-8af6-4c20-93b0-0d0bb76d9501)\r\n\r\n**SAVED
OBJECTS FINDER:
AFTER**\r\n\r\n![lfdgnhklfd-after](https://github.com/user-attachments/assets/e8e007b9-91f7-4209-bfd5-ce43a2cbc894)\r\n\r\n##
Checklist\r\n - [x] Ensure that filtering using `type:` and `tags:`
still
works","sha":"460ca2a83f0fd14b9d8c78c6b695e742c3f25930","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:SharedUX","v8.16.0","backport:version"],"title":"[Global
Search, Saved Objects Management] Use new parse option to specify
recognized
fields","number":190464,"url":"https://github.com/elastic/kibana/pull/190464","mergeCommit":{"message":"[Global
Search, Saved Objects Management] Use new parse option to specify
recognized fields (#190464)\n\nThis PR adds a new option to the
`SchemaType` interface for parsing a\r\nquery from a search in
EuiSearchBar. This new field controls how\r\nEuiSearchBar text is parsed
into a Query object. It enables better\r\naccuracy in how search terms
are parsed when they include a `:`\r\ncharacter.\r\n\r\n## Release
note\r\nFixed an issue when using search bars with a term that includes
a colon\r\n`:` character.\r\n\r\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/184496\r\nDepends on
https://github.com/elastic/eui/pull/7960\r\n\r\n**GLOBAL SEARCH:
BEFORE**\r\n\r\n![akshfgkalsfh-before](https://github.com/user-attachments/assets/22377a3e-394e-43fb-83db-ae2477ce22d7)\r\n\r\n**GLOBAL
SEARCH:
AFTER**\r\n\r\n![akshfgkalsfh-after](https://github.com/user-attachments/assets/406d56eb-c946-493b-94f3-abb0380611f3)\r\n\r\n**SAVED
OBJECTS MANAGEMENT:
BEFORE**\r\n\r\n![okjoyofjiuh-before](https://github.com/user-attachments/assets/c1c56572-31aa-41df-b0c5-3eef421a06c5)\r\n\r\n**SAVED
OBJECTS MANAGEMENT:
AFTER**\r\n\r\n![okjoyofjiuh-after](https://github.com/user-attachments/assets/9e19bbcf-72e7-43d5-a9e7-3c5805632a38)\r\n\r\n**SAVED
OBJECTS FINDER:
BEFORE**\r\n\r\n![lfdgnhklfd-before](https://github.com/user-attachments/assets/b826987d-8af6-4c20-93b0-0d0bb76d9501)\r\n\r\n**SAVED
OBJECTS FINDER:
AFTER**\r\n\r\n![lfdgnhklfd-after](https://github.com/user-attachments/assets/e8e007b9-91f7-4209-bfd5-ce43a2cbc894)\r\n\r\n##
Checklist\r\n - [x] Ensure that filtering using `type:` and `tags:`
still
works","sha":"460ca2a83f0fd14b9d8c78c6b695e742c3f25930"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/190464","number":190464,"mergeCommit":{"message":"[Global
Search, Saved Objects Management] Use new parse option to specify
recognized fields (#190464)\n\nThis PR adds a new option to the
`SchemaType` interface for parsing a\r\nquery from a search in
EuiSearchBar. This new field controls how\r\nEuiSearchBar text is parsed
into a Query object. It enables better\r\naccuracy in how search terms
are parsed when they include a `:`\r\ncharacter.\r\n\r\n## Release
note\r\nFixed an issue when using search bars with a term that includes
a colon\r\n`:` character.\r\n\r\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/184496\r\nDepends on
https://github.com/elastic/eui/pull/7960\r\n\r\n**GLOBAL SEARCH:
BEFORE**\r\n\r\n![akshfgkalsfh-before](https://github.com/user-attachments/assets/22377a3e-394e-43fb-83db-ae2477ce22d7)\r\n\r\n**GLOBAL
SEARCH:
AFTER**\r\n\r\n![akshfgkalsfh-after](https://github.com/user-attachments/assets/406d56eb-c946-493b-94f3-abb0380611f3)\r\n\r\n**SAVED
OBJECTS MANAGEMENT:
BEFORE**\r\n\r\n![okjoyofjiuh-before](https://github.com/user-attachments/assets/c1c56572-31aa-41df-b0c5-3eef421a06c5)\r\n\r\n**SAVED
OBJECTS MANAGEMENT:
AFTER**\r\n\r\n![okjoyofjiuh-after](https://github.com/user-attachments/assets/9e19bbcf-72e7-43d5-a9e7-3c5805632a38)\r\n\r\n**SAVED
OBJECTS FINDER:
BEFORE**\r\n\r\n![lfdgnhklfd-before](https://github.com/user-attachments/assets/b826987d-8af6-4c20-93b0-0d0bb76d9501)\r\n\r\n**SAVED
OBJECTS FINDER:
AFTER**\r\n\r\n![lfdgnhklfd-after](https://github.com/user-attachments/assets/e8e007b9-91f7-4209-bfd5-ce43a2cbc894)\r\n\r\n##
Checklist\r\n - [x] Ensure that filtering using `type:` and `tags:`
still
works","sha":"460ca2a83f0fd14b9d8c78c6b695e742c3f25930"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Tim Sullivan <tsullivan@users.noreply.github.com>
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 Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)
Projects
None yet
5 participants