You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe
The Context Suggester in OpenSearch lacks the ability to process multiple contexts as AND conditions. In the
current implementation, when multiple contexts are specified in a single Suggest query, they are processed as OR
conditions.
For example, if you want to get suggestions that match both a "cafe" category AND a specific geographic
location, the current Context Suggester will return items that match either the "cafe" category OR the specified
geographic location. This behavior is counterintuitive, as in many use cases, users typically want to combine
multiple contexts with AND conditions.
Currently, to work around this limitation, we need to use approaches such as:
Preparing multiple Suggest fields and including separate contexts in each field
Specifying multiple Suggest conditions within a single query and processing the results on the client side
These workarounds make implementation complex and require additional processing on the client side, which is not
an ideal solution.
Describe the solution you'd like
I would like to add functionality to the Context Suggester to process multiple contexts as either AND or OR
conditions. Specifically, the following features are needed:
Provide an option to process multiple contexts specified in a single Suggest query as AND conditions
Allow explicit specification of logical operators (AND/OR) between contexts
For example, it would be beneficial to have syntax like:
This improvement would allow users to execute suggest queries that combine multiple context conditions
intuitively and efficiently without using complex workarounds. This would be particularly useful when
implementing suggestion features that consider both geographic location and categories.
Related component
Search:Query Capabilities
Describe alternatives you've considered
I've explored several workarounds to address the current limitation:
Multiple Suggest Fields Approach: Creating separate completion fields for each context type and querying them
individually. This requires maintaining multiple fields with redundant data and performing client-side
intersection of results.
Multiple Suggest Queries in a Single Request: Using multiple suggest queries within the same request, each
with a different context, and then intersecting the results client-side.
tkykenmt
changed the title
[Feature Request] <title>
[Feature Request] Context Suggester: Add support for AND logic between multiple contexts
Mar 25, 2025
Is your feature request related to a problem? Please describe
The Context Suggester in OpenSearch lacks the ability to process multiple contexts as AND conditions. In the
current implementation, when multiple contexts are specified in a single Suggest query, they are processed as OR
conditions.
For example, if you want to get suggestions that match both a "cafe" category AND a specific geographic
location, the current Context Suggester will return items that match either the "cafe" category OR the specified
geographic location. This behavior is counterintuitive, as in many use cases, users typically want to combine
multiple contexts with AND conditions.
Currently, to work around this limitation, we need to use approaches such as:
These workarounds make implementation complex and require additional processing on the client side, which is not
an ideal solution.
Describe the solution you'd like
I would like to add functionality to the Context Suggester to process multiple contexts as either AND or OR
conditions. Specifically, the following features are needed:
For example, it would be beneficial to have syntax like:
This improvement would allow users to execute suggest queries that combine multiple context conditions
intuitively and efficiently without using complex workarounds. This would be particularly useful when
implementing suggestion features that consider both geographic location and categories.
Related component
Search:Query Capabilities
Describe alternatives you've considered
I've explored several workarounds to address the current limitation:
individually. This requires maintaining multiple fields with redundant data and performing client-side
intersection of results.
with a different context, and then intersecting the results client-side.
Additional context
• elastic/elasticsearch#24421
• elastic/elasticsearch#21291
• elastic/elasticsearch#26407
The text was updated successfully, but these errors were encountered: