Skip to content

Commit

Permalink
[ES|QL][Lens] Fixes the filter out legend action (#194374)
Browse files Browse the repository at this point in the history
## Summary

Closes #194373

Fixes the filter out legend action

### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
stratoula authored Sep 30, 2024
1 parent b5c2169 commit abffb37
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,23 @@ describe('createFiltersFromClickEvent', () => {
expect(queryString).toEqual(`from meow
| WHERE \`columnA\`=="2048"`);
});

test('should return the update query string for negated action', async () => {
dataPoints[0].table.columns[0] = {
name: 'columnA',
id: 'columnA',
meta: {
type: 'string',
},
};
const queryString = await appendFilterToESQLQueryFromValueClickAction({
data: dataPoints,
query: { esql: 'from meow' },
negate: true,
});

expect(queryString).toEqual(`from meow
| WHERE \`columnA\`!="2048"`);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export const createFiltersFromValueClickAction = async ({
export const appendFilterToESQLQueryFromValueClickAction = ({
data,
query,
negate,
}: ValueClickDataContext) => {
if (!query) {
return;
Expand All @@ -183,6 +184,12 @@ export const appendFilterToESQLQueryFromValueClickAction = ({
if (value == null) {
return;
}
return appendWhereClauseToESQLQuery(query.esql, column.name, value, '+', column.meta?.type);
return appendWhereClauseToESQLQuery(
query.esql,
column.name,
value,
negate ? '-' : '+',
column.meta?.type
);
}
};

0 comments on commit abffb37

Please sign in to comment.