Skip to content

Commit

Permalink
updated hybrid_search vs. enable_hybrid_search handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rustonaut committed Nov 15, 2023
1 parent 4274781 commit 4aa633f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
6 changes: 3 additions & 3 deletions web-api/openapi/front_office.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ paths:
For web sites, consider triggering this method whenever a certain document url loads, preferably after the user spent some time on the page, in order to prevent false positives.
For apps, consider implementing a "like" button, where the on-click triggers this method.
Please remember that it is recommended to register a reaction with the specific snippet the user
Please remember that it is recommended to register a reaction with the specific snippet the user
interacted with instead of the document as a whole. You can do so by providing snippet ids instead of document ids.
operationId: updateUserInteractions
parameters:
Expand Down Expand Up @@ -502,8 +502,8 @@ components:
user:
$ref: './schemas/user.yml#/InputUser'
enable_hybrid_search:
description: Enable the hybrid search mode.
deprecated: Use `hybrid_search` instead.
description: Deprecated, is now an alias for hybrid_search.
deprecated: true
type: boolean
default: false
hybrid_search:
Expand Down
25 changes: 5 additions & 20 deletions web-api/src/personalization/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,8 @@ struct UnvalidatedSemanticSearchRequest {
count: Option<usize>,
published_after: Option<DateTime<Utc>>,
personalize: Option<UnvalidatedPersonalize>,
#[serde(default)]
enable_hybrid_search: Option<bool>,
#[serde(default)]
hybrid_search: Option<UnvalidatedHybridSearch>,
#[serde(default, alias = "enable_hybrid_search")]
hybrid_search: UnvalidatedHybridSearch,
#[serde(default, rename = "_dev")]
dev: DevOption,
#[serde(default = "default_include_properties")]
Expand All @@ -455,19 +453,9 @@ enum UnvalidatedHybridSearch {
Variant(HybridSearchVariantWithSettings),
}

impl UnvalidatedHybridSearch {
fn merge(search: Option<Self>, enable_hybrid_search: Option<bool>) -> Result<Self, Error> {
Ok(match (search, enable_hybrid_search) {
(None, None) => UnvalidatedHybridSearch::Switch(false),
(Some(search), None) => search,
(None, Some(switch)) => UnvalidatedHybridSearch::Switch(switch),
(Some(_), Some(_)) => {
return Err(BadRequest::from(
"use only either `hybrid_search` or `enable_hybrid_search`",
)
.into())
}
})
impl Default for UnvalidatedHybridSearch {
fn default() -> Self {
Self::Switch(false)
}
}

Expand Down Expand Up @@ -596,7 +584,6 @@ impl UnvalidatedSemanticSearchRequest {
count,
published_after,
personalize,
enable_hybrid_search,
dev,
include_properties,
include_snippet,
Expand All @@ -618,8 +605,6 @@ impl UnvalidatedSemanticSearchRequest {
num_candidates,
)?;

let hybrid_search = UnvalidatedHybridSearch::merge(hybrid_search, enable_hybrid_search)?;

let search_strategy =
SearchStrategy::validate_and_create_from(&embedding_source, hybrid_search, dev.hybrid)?;

Expand Down

0 comments on commit 4aa633f

Please sign in to comment.