Skip to content

Conversation

svilen-mihaylov-elastic
Copy link
Contributor

@svilen-mihaylov-elastic svilen-mihaylov-elastic commented Feb 5, 2025

Adds options to QSTR function.

#118619 added named function parameters. This PR uses this mechanism for allowing query string function parameters, so query string parameters can be used in ES|QL.

Closes #120933

@svilen-mihaylov-elastic svilen-mihaylov-elastic marked this pull request as draft February 5, 2025 16:12
@svilen-mihaylov-elastic svilen-mihaylov-elastic force-pushed the svilen/120933 branch 8 times, most recently from d15c264 to 6e70003 Compare February 10, 2025 21:27
Copy link
Contributor

Warning

It looks like this PR modifies one or more .asciidoc files. These files are being migrated to Markdown, and any changes merged now will be lost. See the migration guide for details.

Copy link
Contributor

Warning

It looks like this PR modifies one or more .asciidoc files. These files are being migrated to Markdown, and any changes merged now will be lost. See the migration guide for details.

Copy link
Contributor

Warning

It looks like this PR modifies one or more .asciidoc files. These files are being migrated to Markdown, and any changes merged now will be lost. See the migration guide for details.

@svilen-mihaylov-elastic svilen-mihaylov-elastic marked this pull request as ready for review February 11, 2025 20:40
@elasticsearchmachine elasticsearchmachine added the needs:triage Requires assignment of a team area label label Feb 11, 2025
@svilen-mihaylov-elastic
Copy link
Contributor Author

Still TODO: add randomized test, take care of documentation warnings

@svilen-mihaylov-elastic svilen-mihaylov-elastic added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Feb 11, 2025
@elasticsearchmachine elasticsearchmachine removed the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Feb 11, 2025
@svilen-mihaylov-elastic svilen-mihaylov-elastic added Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch :Search Relevance/Search Catch all for Search Relevance labels Feb 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Feb 11, 2025
Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good! 💯

Some things I miss:

  • CSV tests for having an end-to-end test of some option
  • Some testing in MatchTests that adds the function named param types

I left some other comments to address, but this is almost done.

|===
name | types | description
fuzziness | [keyword] | Maximum edit distance allowed for matching.
auto_generate_synonyms_phrase_query | [boolean] | If true, match phrase queries are automatically created for multi-term synonyms.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize now that the docs generate options unsorted - we should probably change AbstractFunctionTestCase so it outputs an ordered options list.

No need to do in this PR, can be a follow up.

String optionName = allowedOptions.getKey();
DataType optionType = allowedOptions.getValue();
// Check every possible type for the option - we'll try to convert it to the expected type
for (DataType currentType : optionTypes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably extract this testing code to a separate method so both match and qstr can reuse it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This belongs to QL and not ESQL - I'd say let's keep this out of the scope for this PR

Copy link
Contributor Author

@svilen-mihaylov-elastic svilen-mihaylov-elastic Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that. Since I'm touching a related area, and since there was a TODO to update the constants to fields, I thought it is a good idea to make the change now that the query string builder constants are public.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing the additional named param types in the tests, so the named parameters param is added to the function types. See how match did it here.

…expression/function/fulltext/QueryString.java

Co-authored-by: Carlos Delgado <[email protected]>
Copy link
Contributor

Warning

It looks like this PR modifies one or more .asciidoc files. These files are being migrated to Markdown, and any changes merged now will be lost. See the migration guide for details.

Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Good work! 💯

There's a pending comment about adding default values to the options in the docs

@carlosdelest
Copy link
Member

@svilen-mihaylov-elastic I'm adding backports for 8.19 and 9.0, plus auto-backport for creating them after merge

@carlosdelest carlosdelest added auto-backport Automatically create backport pull requests when merged v9.0.0 v8.19.0 labels Mar 5, 2025
@svilen-mihaylov-elastic
Copy link
Contributor Author

@elasticsearchmachine test this

@elasticsearchmachine
Copy link
Collaborator

Hi @svilen-mihaylov-elastic, I've updated the changelog YAML for you.

Copy link
Member

@fang-xing-esql fang-xing-esql left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @svilen-mihaylov-elastic!

@svilen-mihaylov-elastic svilen-mihaylov-elastic merged commit ee4bcac into elastic:main Mar 7, 2025
16 of 17 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
9.0 Commit could not be cherrypicked due to conflicts
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 121787

georgewallace pushed a commit to georgewallace/elasticsearch that referenced this pull request Mar 11, 2025
Adds options to QSTR function.

elastic#118619 added named function parameters. This PR uses this mechanism for allowing query string function parameters, so query string parameters can be used in ES|QL.

Closes elastic#120933
svilen-mihaylov-elastic added a commit to svilen-mihaylov-elastic/elasticsearch that referenced this pull request Mar 18, 2025
Adds options to QSTR function.

elastic#118619 added named function parameters. This PR uses this mechanism for allowing query string function parameters, so query string parameters can be used in ES|QL.

Closes elastic#120933

(cherry picked from commit ee4bcac)

# Conflicts:
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java
@svilen-mihaylov-elastic
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x
9.0

Questions ?

Please refer to the Backport tool documentation

svilen-mihaylov-elastic added a commit to svilen-mihaylov-elastic/elasticsearch that referenced this pull request Mar 18, 2025
Adds options to QSTR function.

elastic#118619 added named function parameters. This PR uses this mechanism for allowing query string function parameters, so query string parameters can be used in ES|QL.

Closes elastic#120933

(cherry picked from commit ee4bcac)

# Conflicts:
#	x-pack/plugin/esql/qa/testFixtures/src/main/resources/qstr-function.csv-spec
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java
elasticsearchmachine pushed a commit that referenced this pull request Mar 18, 2025
…5114)

* Added optional parameters to QSTR ES|QL function (#121787)

Adds options to QSTR function.

#118619 added named function parameters. This PR uses this mechanism for allowing query string function parameters, so query string parameters can be used in ES|QL.

Closes #120933

(cherry picked from commit ee4bcac)

# Conflicts:
#	x-pack/plugin/esql/qa/testFixtures/src/main/resources/qstr-function.csv-spec
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java

* [CI] Auto commit changes from spotless

* Fix compilation error

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Mar 18, 2025
…5112)

* Added optional parameters to QSTR ES|QL function (#121787)

Adds options to QSTR function.

#118619 added named function parameters. This PR uses this mechanism for allowing query string function parameters, so query string parameters can be used in ES|QL.

Closes #120933

(cherry picked from commit ee4bcac)

# Conflicts:
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

* [CI] Auto commit changes from spotless

* Fix compilation error

* Fix missing import

* getFirst() -> get(0)

* Make method public

* Make asBuilder public in subclasses

* Revert "Make asBuilder public in subclasses"

This reverts commit f444aa6.

* Revert "Make method public"

This reverts commit a1d9f56.

* .asQueryBuilder() -> .toQueryBuilder()

* Remove extraneous change which sneaked in during backport

---------

Co-authored-by: elasticsearchmachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged backport pending >feature :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ESQL - Add options to QSTR function

6 participants