[Dashboard] Fix Phrase_filter query for scripted fields (#148942) (#148943)

- ISSUE [Dashboard] Visualize Library doesn't work filter on scripted
fields of Array Type. #148942

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Lukas Olson <lukas@elastic.co>
This commit is contained in:
LEE SEUNGHYO 2023-01-24 17:29:11 +09:00 committed by GitHub
parent 611e5af179
commit 95c2493e77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -134,7 +134,7 @@ describe('buildInlineScriptForPhraseFilter', () => {
};
const expected =
`boolean compare(Supplier s, def v) {return s.get() == v;}` +
`boolean compare(Supplier s, def v) {if(s.get() instanceof List){List list = s.get(); for(def k : list){if(k==v){return true;}}return false;}else{return s.get() == v;}}` +
`compare(() -> { return foo; }, params.value);`;
expect(buildInlineScriptForPhraseFilter(field)).toBe(expected);

View file

@ -148,7 +148,7 @@ export const buildInlineScriptForPhraseFilter = (scriptedField: DataViewFieldBas
// We must wrap painless scripts in a lambda in case they're more than a simple expression
if (scriptedField.lang === 'painless') {
return (
`boolean compare(Supplier s, def v) {return s.get() == v;}` +
`boolean compare(Supplier s, def v) {if(s.get() instanceof List){List list = s.get(); for(def k : list){if(k==v){return true;}}return false;}else{return s.get() == v;}}` +
`compare(() -> { ${scriptedField.script} }, params.value);`
);
} else {