Skip to content

Feature request: Add support for o19s Elasticsearch LTR Plugin #1026

@kurakura967

Description

@kurakura967

Hi team.

I would like to propose adding support for the o19s Elasticsearch Learning to Rank plugin's sltr query type, which is used within rescore queries. This would require creating new struct definitions similar to the existing LearningToRank struct, but specifically designed for the o19s LTR plugin's query pattern.

I'm happy to contribute the implementation and tests if this proposal aligns with the project's direction.

Proposal

Create a new file typedapi/types/sltr.go (or similar) with dedicated struct definitions for o19s LTR plugin support.

package types

type Sltr struct {
    Model string `json:"model"`  
    Params map[string]interface{} `json:"params,omitempty"`
}

// SltrQuery wraps the SLTR query for use in queries
type SltrQuery struct {
    Sltr Sltr `json:"sltr"`
}

Usecase

This would enable type-safe construction of o19s LTR rescore queries:

rescore := types.Rescore{
    WindowSize: 1000,
    Query: &types.RescoreQuery{
        RescoreQuery: &types.Query{
            // SltrQuery would need to be added as a field in Query struct
            Sltr: &types.SltrQuery{
                Sltr: types.Sltr{
                    Model: "my_trained_model",
                    Params: map[string]interface{}{
                        "query": "elasticsearch",
                        "user_id": "user123",
                    },
                },
            },
        },
    },
}

Current Limitation

The existing LearningToRank struct in typedapi/types/learningtorank.go cannot represent the sltr query pattern used by the o19s plugin in rescore contexts.

o19s LTR Plugin Query Pattern:

{
  "query": {
    "bool": {
      "must": {"match_all": {}},
      "filter": {"match": {"title": "search term"}}
    }
  },
  "rescore": {
    "window_size": 1000,
    "query": {
      "rescore_query": {
        "sltr": {
          "params": {},
          "model": "my_model_name"
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions