opensearch-project / opensearch-java

Java Client for OpenSearch
Apache License 2.0
105 stars 169 forks source link

[FEATURE] Add search_pipeline query param to SearchRequest #1030

Closed jdomkline closed 2 weeks ago

jdomkline commented 2 weeks ago

Is your feature request related to a problem?

Well, the HybridSearch query, in pure DSL, can take in a search_pipeline query. This param targets a pipeline that allows a weighting of search types. Here is a reference, https://opensearch.org/docs/latest/search-plugins/neural-search-tutorial/#step-2-search-with-the-hybrid-query. Note "GET /my-nlp-index/_search?search_pipeline=nlp-search-pipeline"

I could not find a way to do this with the current Java client, so I patched class org.opensearch.client.opensearch.core.SearchRequest to get the param added the same way it is handled for other params.

    if (request.batchedReduceSize != null) {
      params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize));
    }
    if (request.searchPipeline != null) {
      params.put("search_pipeline", request.searchPipeline);
    }
    return params;

With all applicable changes in the static builder.

What solution would you like?

I would like my forthcoming PR to be accepted to allow others to run Hybrid queries with this param also.

What alternatives have you considered?

Not really, as there are so many similar examples in the current codebase. In my patch, I made another class, HybridSearchRequest, that was essentially a copy of SearchRequest with these simple changes. I don't think this change merits a new class, I only did this to avoid more complexity with the patch.

If a new class is preferred I can do that, please advise.

Do you have any additional context?

Well again the tutorial... https://opensearch.org/docs/latest/search-plugins/neural-search-tutorial/#step-2-search-with-the-hybrid-query

jdomkline commented 2 weeks ago

I see this is a dup from a ticket from 3 days ago.. closing.

jdomkline commented 2 weeks ago

Dup to a tix recently added and addressed.