-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Searching for saved objects with dashes shows no results #5734
Comments
I was able to work around this while trying to figure out what was going on (though the workaround didn't make sense). I created a visualization called foo-bar-baz and was able to find it a couple of ways:
This likely happens because - is a reserved character in the elasticsearch query. One possible solution would be to under the hood wrap the query with quotes if it contains any keywords but I could imagine that causing other issues for searches. |
This is because saved objects title field is analyzed using the standard analyzer which will break on the
This feels related to #4563. |
Pinging @elastic/kibana-platform |
additionally, this causes issues when searching for items with |
This topic comes up regularily, most often (as far as I can tell) also because of people having After some discussion we think it might make sense tweaking the standard analyzer for those fields a bit to at least make Thus we think we should have discussion whether it makes instead sense having some kind of mechanism in the central saved object services for that. I am not sure yet exactly how this would look like, but a couple of ideas would be:
I personally would really prefer if we could not introduce bad UX by introducing different analyzed title fields. @elastic/kibana-platform what are your thoughts on that? |
👍 The search box already searches is set field names ( |
I've just confirmed that this is still an issue with 7.5.0. |
Still the same on 7.5.1. |
I received a report for this against 7.8.1 today. Appending a space at the end of the search is the simplest workaround. Appending a
While the reason for the behavior makes sense, I think we could do better service to the many running into this limitation by either finding a way to fix it or documenting the workaround. Let's do something with it and close the issue. Edit: The report I received was against searching for index patterns containing the common |
Would it be possible to apply the |
Regardless of the technical fix it seems very counter-intuitive to give a free form search modal and not have the results be free form. I understand there are technical limitations around the leading/trailing wild carding against index pattern titles, but if the back end ES isn't capable of loose matching, then at least the full index pattern result set could be passed to the local browser client and searched client-side with js or something. Relying on local client side js would obviously be sub-optimal in a product, you know, for search. It is a poor UX limitation and will be experienced frequently on any customer with many nested index patterns/clusters. |
So, after discussing with the ES team, it seems we have two options to solve this: (#20242 shares the same root issue and will also be solved by this) Changing the analyzer / tokenizer we are using for SO'sTo allow to properly search for special chars such as The analyzer would look like PUT /.kibana_1/_settings
{
"analysis": {
"filter": {
"ascii_folding_preserve": {
"type" : "asciifolding",
"preserve_original": "true"
}
},
"analyzer": {
"include_special_character": {
"type": "custom",
"filter": [
"lowercase",
"ascii_folding_preserve"
],
"tokenizer": "whitespace"
}
}
}
} Pros:More powerful for 'fulltext' searchWe can really search for terms with special chars. Searching for Cons:require changes on the SO migration mechanismWe can't update the settings of the index without closing it, meaning that we will need to add this new analyzer during a 'migration'. Atm, the migration triggers only if there is a mismatch in
need to decide if we put this analyzer at the index level, or on a per-field basisIndex level seems dangerous. Per-field basis requires to find an acceptable logic for that. Setting the analyzer at default for the we may be breaking some usages of the
|
if (search) { | |
bool.must = [ | |
{ | |
simple_query_string: { | |
query: search, | |
...getFieldsForTypes(types, searchFields, rootSearchFields), | |
...(defaultSearchOperator ? { default_operator: defaultSearchOperator } : {}), | |
}, | |
}, | |
]; | |
} | |
return { query: { bool } }; |
would become
if (search) {
const fields = getFieldsForTypes(types, searchFields, rootSearchFields);
bool.must = [
{
bool: {
should: [
{
simple_query_string: {
query: search,
...fields,
...(defaultSearchOperator ? { default_operator: defaultSearchOperator } : {}),
},
},
// TODO: check if '*'
...fields.fields.map((field) => ({
match_phrase_prefix: {
[field]: search.replace(/[*]$/, ''), // need to remove the prefix search operator if present
},
})),
],
minimum_should_match: 1,
},
},
];
}
That way we are able to, more or less, simulate a search for the exact term by searching with phrase prefix for all of its tokens.
search for my-dash
will search for phrase prefix ['my', 'dash']
Pros
Way simpler to implement
We are not touching the migration nor our fields analyzer. Just one file, src/core/server/saved_objects/service/lib/search_dsl/query_params.ts
Less risks to break existing usages of the find
API
We are not altering the current simple_query_string
and are using an inclusive should
clause, meaning that all results that were previously returned still will. Worse case, more results will be returned, which seems more acceptable than less.
Cons
We are not really searching for the special characters
We are just 'cheating' with match_phrase_prefix
, so it's a little less powerful.
For example, searching for test*dash
is actually searching for match_phrase_prefix: ['test', 'dash*']
. Any special character used as token separator by the tokenizer can match.
As an example:
In the same logic, searching for it-
is the exact same thing as searching for it
(well, except that it will work, which is not the case atm). We can't still 'really' search for special chars as a last character of our search term, it will just be ignored.
Overall
I think solution 2 is 'good enough', as it solves main of the problems our end users are encountering, while being the safest one, so I would go with it.
@elastic/kibana-platform what do you think?
We discussed this as a team and agreed that solution 2 would be a good stop-gap in the short term. Longer term, we feel like Kibana should have powerful full-text search which requires option 1, but it's worth taking the time to properly flesh this out. We would probably want to change |
Related #14729 |
While trying to search for either saved queries/visualizations/dashboards that contain dashes comes up blank if you start typing a name and right after typing in a dash. I tried using backslash and putting the search in double quotes (doesn't seem to make a difference).
I am using Kibana 4.1.3
Note: when we change the analyzer for any fields, we should to be sure migrations are triggered.
The text was updated successfully, but these errors were encountered: