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

[BUG] Error doing pagination with hybrid searches #15350

Open
sonic182 opened this issue Aug 22, 2024 · 1 comment
Open

[BUG] Error doing pagination with hybrid searches #15350

sonic182 opened this issue Aug 22, 2024 · 1 comment
Labels
bug Something isn't working Search Search query, autocomplete ...etc

Comments

@sonic182
Copy link

sonic182 commented Aug 22, 2024

Describe the bug

When doing pagination with an hybrid query and a search pipeline, I receive the following error: score normalization processor cannot produce final query result, the number of documents after fetch phase [10] is different from number of documents from query phase [12]

Maybe duplicated of opensearch-project/neural-search#280

query and response:

# query
 %{
  "_source" => %{"exclude" => ["vector"], "includes" => []},
  "aggs" => %{
    "group_count" => %{
      "aggs" => %{
        "total" => %{
          "cardinality" => %{
            "field" => "grouping_id",
            "precision_threshold" => 1000
          }
        }
      },
      "filter" => %{"bool" => %{"must" => []}}
    }
  },
  "collapse" => %{"field" => "grouping_id"},
  "from" => 2,
  "post_filter" => %{"bool" => %{"must" => []}},
  "query" => %{
    "hybrid" => %{
      "queries" => [
        %{
          "function_score" => %{
            "boost_mode" => "sum",
            "query" => %{
              "function_score" => %{
                "functions" => [
                  %{
                    "field_value_factor" => %{
                      "field" => "manual_boost",
                      "missing" => 1
                    }
                  },
                  %{
                    "field_value_factor" => %{
                      "field" => "auto_boost",
                      "missing" => 1
                    }
                  }
                ],
                "query" => %{
                  "dis_max" => %{
                    "queries" => [
                      %{
                        "bool" => %{
                          "minimum_should_match" => 1,
                          "should" => [
                            %{
                              "multi_match" => %{
                                "cutoff_frequency" => 0.1,
                                "fields" => ["brand^2", "categories^2",
                                 "all^1", "gtin^1", "mpn^1", "title^3",
                                 "title.autocomplete^1"],
                                "operator" => "and",
                                "query" => "aifon 13",
                                "type" => "best_fields"
                              }
                            }
                          ]
                        }
                      },
                      %{
                        "bool" => %{
                          "minimum_should_match" => 1,
                          "should" => [
                            %{
                              "multi_match" => %{
                                "cutoff_frequency" => 0.1,
                                "fields" => ["brand^2", "categories^2",
                                 "all^1", "gtin^1", "mpn^1", "title^3",
                                 "title.autocomplete^1"],
                                "query" => "aifon 13",
                                "type" => "best_fields"
                              }
                            }
                          ]
                        }
                      }
                    ],
                    "tie_breaker" => 0.3
                  }
                }
              }
            },
            "score_mode" => "max"
          }
        },
        %{
          "knn" => %{
            "vector" => %{
              "k" => 30,
              "vector" => [-0.047876860946416855, 0.05234730988740921,
               0.01735660620033741, 0.03566263988614082, -0.020095694810152054,
               0.005881187971681356, 0.08795266598463058, 0.01124920230358839,
               0.026371607556939125, -0.027546236291527748,
               -0.06709688901901245, -0.030416270717978477, 0.05761145427823067,
               0.04374939948320389, -0.004689693916589022, 0.02921660803258419,
               0.016390908509492874, -0.005048255901783705,
               0.027706122025847435, -0.006353649776428938,
               -0.022267673164606094, 0.05834672600030899,
               -0.024640902876853943, 0.025103332474827766,
               -0.023313814774155617, -0.03295905515551567,
               0.0069340369664132595, -0.018305879086256027,
               -0.02108374983072281, 0.041981711983680725,
               -1.7442446551285684e-4, -0.015122073702514172,
               0.014571044594049454, 0.036353059113025665, 0.004828275181353092,
               -0.012067032046616077, ...]
            }
          }
        }
      ]
    }
  },
  "size" => 2,
  "sort" => [%{"_score" => "desc"}],
  "track_scores" => true
}

# RESPONSE
%{
 "error" => %{
   "caused_by" => %{
     "reason" => "score normalization processor cannot produce final query result, the number of documents after fetch phase [10] is different from number of documents from query phase [12]",
     "type" => "illegal_state_exception"
   },
   "failed_shards" => [],
   "grouped" => true,
   "phase" => "query",
   "reason" => "The phase has failed",
   "root_cause" => [],
   "type" => "search_phase_execution_exception"
 },
 "status" => 500
}

Related component

Search

To Reproduce

  1. have an index with a vector field
  2. do an hybrid query with "from" and "size" params
  3. See error

Expected behavior

Working pagination

Additional Details

Plugins

  • icu-analyzer

Screenshots

Host/Environment (please complete the following information):

  • OS: docker opensearch 2.16.0

Additional context

@sonic182 sonic182 added bug Something isn't working untriaged labels Aug 22, 2024
@github-actions github-actions bot added the Search Search query, autocomplete ...etc label Aug 22, 2024
@sandeshkr419
Copy link
Contributor

Search Triage: @martin-gaievski - Do you want to a take a look once?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Search Search query, autocomplete ...etc
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants