Skip to content

ESQL - Add options to QSTR function #120933

@carlosdelest

Description

@carlosdelest

Description

#120360 added options to MATCH function. We want to add options to the QSTR function as well.

Steps for doing this would be:

Modify QueryStringQuery in ESQL

  • Reference the fields used in the query builder instead of creating new constants, like here.
  • Change the constructor so options are passed in as a Map<String, Object>

Modify QueryString function to implement options:

  • Make it implement OptionalArgument as a marker for adding a new optional param
  • Get the supported options from query string query (similar to this)
  • Add them to the documentation in the form of @MapParam annotation (like here)
  • Add constructors to provide options as an additional expression (here)
  • We'll need to resolve the types for the provided options to ensure that they are valid. This is the work done in match - we probably want some utility class or method on a superclass to deal with common code here.
  • We'll need to create a Map with the options to provide them to the QueryStringQuery in the translate() method.

Add tests

  • Add tests to AnalyzerTests (similar to this ) to ensure the analysis is done properly and options are included in the query builder.
  • Add tests to VerifierTests (similar to these) to ensure verification is done for the option types, and they work as expected.
  • Add tests to QueryStringTests so we test all the combinations for the types, similar to this. Tests that extend from AbstractFunctionTestCase also generates docs under /docs/reference/esql/functions based on the constructor annotations and the types that are used as test cases in the corresponding function test.
  • Add tests to LocalPhysicalPlanOptimizerTests to ensure options are translated into the actual query when it gets pushed down to Lucene (see here).

Add docs

  • Docs should be generated automatically from the constructor annotations. Check that we are referencing the <<esql-function-named-params,function named parameters>> so users can look at details on how to pass function named params.
  • If you change the doc annotations, run QueryStringTests to re-generate them.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions