Skip to content
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

Allow alternate / native search syntax #293

Closed
ralfhandl opened this issue Mar 20, 2024 · 3 comments · Fixed by oasis-tcs/odata-vocabularies#241 or #1918
Closed

Allow alternate / native search syntax #293

ralfhandl opened this issue Mar 20, 2024 · 3 comments · Fixed by oasis-tcs/odata-vocabularies#241 or #1918
Assignees
Labels
Protocol Protocol, URL Conventions V4.02

Comments

@ralfhandl
Copy link
Contributor

ralfhandl commented Mar 20, 2024

When doing text searches, many of the common algorithms we use have a number of different ways to define a match (Exact match, begins with, synonym, base word or inflection, etc). The $search query parameter defines a search syntax but its definition says it is up to the implementation as to what constitutes a match. This is fine, but in the case where the search engine provides different matching types it would be nice if user had a way to specify how the type of match to be used in the search expression.

This was originally filed as ODATA-1100 / #861 as a request to modify the existing $search syntax to support specifying match type. In discussing the proposal for ODATA-1100 with some users, it was suggested that we do not define our own syntax for specifying match type. There are several common search engines that define a syntax that allows the type of match to be specified. The most common of these is currently is Apache Lucene -
https://lucene.apache.org/core/. Instead of expanding the $search syntax, should we provide a way for the user to specify an alternate or native syntax so that they can utilize the underlying capabilities of the search engine? If we do allow alternate syntax, there is likely a need for some metadata describing what if any alternate syntax a service understands.

Proposal

Make $search a pass-through query option, impose no syntax, and impose no other restrictions than what is necessary to parse the URL.

Make V4 $search syntax just an optional recommendation.

Add a Capabilities term of type URL that allows pointing to the search syntax supported by the service, which may be the V4 $search syntax.

Imported from ODATA-1113

@ralfhandl ralfhandl added Protocol Protocol, URL Conventions V4.02 labels Mar 20, 2024
@ralfhandl ralfhandl self-assigned this Mar 20, 2024
@ralfhandl ralfhandl moved this to Open in OData TC Mar 23, 2024
@HeikoTheissen
Copy link
Contributor

Comment by @mikepizzo:

perhaps something like $search:lucene=

could decide if the syntax is a hint or a requirement (since search is fuzzy anyway)

@HeikoTheissen
Copy link
Contributor

Comment by @HeikoTheissen:

An example for context-sensitive search:

StateCode CountryCode search predicate matches?
GA GE search(StateCode, 'Georgia') yes, because GA is the abbreviation of the US state
GA GE search(CountryCode, 'Georgia') yes, because GE is the abbreviation of country Georgia
GA GA search(CountryCode, 'Georgia') no, because GA stands for the country Gabon

In the first row 'Georgia' matches the value 'GA', but in the last row it does not.

Such a behavior could be implemented by mapping OData search expressions to different search models, depending on the property:

OData expression (new syntax proposal) database predicate
State/search('Georgia') contains((State,StateText), 'Georgia')
Country/search('Georgia') contains((Country,CountryText), 'Georgia')

@HeikoTheissen
Copy link
Contributor

SAP wants to use a different search syntax where

  • instances that do not contain the term "red" are found by $search=-red
  • instances that contain the terms "NOT" and "red" are found by $search=NOT red.

This SAP-specific search syntax is already widely used both with OData V2 (search=-red) and outside OData ("Enterprise search").

@ralfhandl ralfhandl moved this from Open to Review in OData TC Apr 10, 2024
@HeikoTheissen HeikoTheissen moved this from Review to Open in OData TC Apr 17, 2024
@HeikoTheissen HeikoTheissen moved this from Open to Review in OData TC May 28, 2024
@github-project-automation github-project-automation bot moved this from Review to Closed in OData TC May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Protocol Protocol, URL Conventions V4.02
Projects
Status: Closed
2 participants