-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[ES|QL] Add support for RRF
#221349
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
Open
sddonne
wants to merge
30
commits into
elastic:main
Choose a base branch
from
sddonne:esql/rrf/ast-parsing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+390
−4
Open
[ES|QL] Add support for RRF
#221349
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
e1d67fb
feat: add rrf node
sddonne 83b0e3e
feat: add rff ast parser tests
sddonne e3b0da1
feat: add rrf to visitor api
sddonne 084f04b
feat: add tests for rrf pretty printer
sddonne d19f0bd
feat: add new rff command and suggestions
sddonne 06a937e
feat: only display RRF command after a FORK
sddonne 832a5fa
feat: only display RRF command after FORK
sddonne 39d8b2d
feat: add tests for rrf autocomplete
sddonne 36dd3c4
feat: add rrf validations and autocomplete tests
sddonne fac9e5c
feat: add validations for rrf command
sddonne 89b6516
fix: typo
sddonne 0779540
Merge branch 'main' into esql/rrf/ast-parsing
elasticmachine 80655ce
add failure test to rrf command parse
sddonne 36fa32d
Merge branch 'esql/rrf/ast-parsing' of https://github.com/sddonne/kib…
sddonne 2130458
fix: parameter not needed
sddonne 37b15c7
unify metada error codes
sddonne c19b90a
reuse definition of the metadata fields
sddonne 297ceca
name it param
sddonne 1a1f07b
add rrf check directly in the suggest function
sddonne c657e50
clean commandsSuggestionsAfter code
sddonne 4ed4fb3
add test to check there is a pipe between fork and rrf
sddonne bb834fd
Merge branch 'main' into esql/rrf/ast-parsing
elasticmachine 6dc16f1
change rrf metadata error warning
sddonne c4a589e
Merge branch 'esql/rrf/ast-parsing' of https://github.com/sddonne/kib…
sddonne c49ed97
Merge branch 'main' into esql/rrf/ast-parsing
stratoula 1d46db4
add rrf test case, when invoked with arguments
sddonne 17ad55c
fix rrf tests formatting
sddonne bdf3b6e
ignore case sensitivity in test regex
sddonne 509ae43
fix wrong test suite name
sddonne 0e16d3d
fix: rrf autosuggest test
sddonne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/platform/packages/shared/kbn-esql-ast/src/parser/__tests__/rrf.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { parse } from '../parser'; | ||
|
||
describe('RRF', () => { | ||
describe('correctly formatted', () => { | ||
it('can parse RRF command without modifiers', () => { | ||
const text = `FROM search-movies METADATA _score, _id, _index | ||
| FORK ( WHERE semantic_title:"Shakespeare" | SORT _score) | ||
( WHERE title:"Shakespeare" | SORT _score) | ||
| RRF | ||
| KEEP title, _score`; | ||
|
||
const { root, errors } = parse(text); | ||
|
||
expect(errors.length).toBe(0); | ||
expect(root.commands[2]).toMatchObject({ | ||
type: 'command', | ||
name: 'rrf', | ||
args: [], | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.command.rff.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { setup } from './helpers'; | ||
|
||
describe('autocomplete.suggest', () => { | ||
describe('RRF', () => { | ||
it('does not suggest RRF in the general list of commands', async () => { | ||
const { suggest } = await setup(); | ||
const suggestedCommands = (await suggest('FROM index | /')).map((s) => s.text); | ||
expect(suggestedCommands).not.toContain('RRF '); | ||
}); | ||
|
||
it('suggests RRF immediately after a FORK command', async () => { | ||
const { suggest } = await setup(); | ||
const suggestedCommands = (await suggest('FROM a | FORK (LIMIT 1) (LIMIT 2) | /')).map( | ||
(s) => s.text | ||
); | ||
expect(suggestedCommands).toContain('RRF '); | ||
}); | ||
|
||
it('does not suggests RRF if FORK is not immediately before', async () => { | ||
const { suggest } = await setup(); | ||
const suggestedCommands = ( | ||
await suggest('FROM a | FORK (LIMIT 1) (LIMIT 2) | LIMIT 1 /') | ||
drewdaemon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
).map((s) => s.text); | ||
expect(suggestedCommands).not.toContain('RRF '); | ||
drewdaemon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
it('suggests pipe after complete command', async () => { | ||
const { assertSuggestions } = await setup(); | ||
await assertSuggestions('FROM a | FORK (LIMIT 1) (LIMIT 2) | RRF /', ['| ']); | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...esql-validation-autocomplete/src/autocomplete/commands/fork/commands_suggestions_after.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { CommandDefinition, getCommandDefinition } from '../../../..'; | ||
import { getCommandAutocompleteDefinitions } from '../../complete_items'; | ||
import { SuggestionRawDefinition } from '../../types'; | ||
|
||
export function commandsSuggestionsAfter(suggestions: SuggestionRawDefinition[]) { | ||
stratoula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return [ | ||
...suggestions, | ||
...getCommandAutocompleteDefinitions([ | ||
{ | ||
...(getCommandDefinition('rrf') as CommandDefinition<string>), | ||
hidden: false, | ||
}, | ||
]), | ||
]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...m/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/commands/rrf/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { CommandSuggestParams } from '../../../definitions/types'; | ||
import type { SuggestionRawDefinition } from '../../types'; | ||
import { pipeCompleteItem } from '../../complete_items'; | ||
|
||
export function suggest(_params: CommandSuggestParams<'rrf'>): SuggestionRawDefinition[] { | ||
stratoula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return [pipeCompleteItem]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.