Skip to content

[FEATURE] Add script_score to query DSL #253

Description

@quangcap

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/

Activity

  1. dblock commented on Jul 8, 2024

    @dblock
    Member

    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

  2. dblock commented on Jul 9, 2024

    @dblock
    Member

    Closed via #254.

  3. quangcap commented on Jul 20, 2024

    @quangcap
    Author

    @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.

  4. dblock commented on Jul 20, 2024

    @dblock
    Member

    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
  5. quangcap commented on Jul 20, 2024

    @quangcap
    Author

    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
    ...
    
  6. dblock commented on Jul 20, 2024

    @dblock
    Member

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions