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

[FEATURE] Add script_score to query DSL #253

Closed
quangcap opened this issue Jul 4, 2024 · 6 comments
Closed

[FEATURE] Add script_score to query DSL #253

quangcap opened this issue Jul 4, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@quangcap
Copy link
Contributor

quangcap commented Jul 4, 2024

Is your feature request related to a problem?

Script Score query was added to OpenSearch 2.9 and current query DSL does not support it.
I use script score a lot in my case, so I would want to add it in current query DSL.

What solution would you like?

Add script_score to query DSL

Do you have any additional context?

OpenSearch document on script_score: https://opensearch.org/docs/latest/query-dsl/specialized/script-score/

@dblock
Copy link
Member

dblock commented Jul 8, 2024

Related, we've been working on https://github.com/opensearch-project/opensearch-api-specification. For this client we need help for someone to pickup #233 and other generator-related work.

@quangcap Now that you're very familiar with this API, would you be able to contribute it to the spec as well? https://github.com/opensearch-project/opensearch-api-specification

@dblock
Copy link
Member

dblock commented Jul 9, 2024

Closed via #254.

@dblock dblock closed this as completed Jul 9, 2024
@quangcap
Copy link
Contributor Author

quangcap commented Jul 20, 2024

@dblock Sorry for the late reply!

About #233: I tried out the ApiGenerator, and it throws a lot of errors, probably because the current parser doesn’t support OAS 3.1 yet. I’ve seen some work being done on the parser (kevindew/openapi3_parser#22), but I don’t think it’ll be ready anytime soon.

As for adding script_score to the spec: Absolutely, I’d love to help out! But I believe script_score query is added in the spec.

@dblock
Copy link
Member

dblock commented Jul 20, 2024

FWIW, I've been able to load the spec with the current openapi3_parser:

require 'open-uri'
require 'openapi3_parser'

openapi_url = "https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml"
openapi_path = "opensearch-openapi.yaml"
File.write(openapi_path, URI.open(openapi_url).read) unless File.exists?(openapi_path)
puts "Loading #{openapi_path} (#{File.size(openapi_path)} byte(s)) ..."

doc = Openapi3Parser.load_file(openapi_path)
puts "Loaded #{openapi_url} with #{doc.paths.size} path(s)."

doc.paths.keys.each do |key|
   puts key
end

@quangcap
Copy link
Contributor Author

quangcap commented Jul 20, 2024

I've been able to load it with the current openapi3_parser. However, running .valid? and .errors, I can print out a lot of errors.

...
doc = Openapi3Parser.load_file(openapi_path)
puts "Loaded #{openapi_url} with #{doc.paths.size} path(s)."
puts "Spec is valid: " + doc.valid?.to_s

puts "Errors:"
doc.errors.each do |err|
  puts err
end

which prints:

Loading opensearch-openapi.yaml (1885141 byte(s)) ...
Loaded https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml with 320 path(s).
Spec is valid: false
Errors:
#/components/parameters/_global%3A%3Aquery.pretty does not resolve to a valid object
#/components/parameters/_global%3A%3Aquery.human does not resolve to a valid object
#/components/parameters/_global%3A%3Aquery.error_trace does not resolve to a valid object
#/components/parameters/_global%3A%3Aquery.pretty does not resolve to a valid object
#/components/parameters/_global%3A%3Aquery.human does not resolve to a valid object
#/components/parameters/_global%3A%3Aquery.error_trace does not resolve to a valid object
#/components/parameters/_global%3A%3Aquery.pretty does not resolve to a valid object
#/components/parameters/_global%3A%3Aquery.human does not resolve to a valid object
#/components/parameters/_global%3A%3Aquery.error_trace does not resolve to a valid object
...

@dblock
Copy link
Member

dblock commented Jul 20, 2024

@quangcap Do you know whether those are legit errors? If they are, please do open an issue in https://github.com/opensearch-project/opensearch-api-specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants