-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added supprt for match bool prefix (#3806)
Closes #3780
- Loading branch information
1 parent
04a6e4a
commit 2409d2b
Showing
9 changed files
with
327 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
quickwit/quickwit-query/src/elastic_query_dsl/match_bool_prefix.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (C) 2023 Quickwit, Inc. | ||
// | ||
// Quickwit is offered under the AGPL v3.0 and as commercial software. | ||
// For commercial licensing, contact us at [email protected]. | ||
// | ||
// AGPL: | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use serde::Deserialize; | ||
|
||
use crate::elastic_query_dsl::match_query::{MatchQueryParams, MatchQueryParamsForDeserialization}; | ||
use crate::elastic_query_dsl::{default_max_expansions, ConvertableToQueryAst}; | ||
use crate::query_ast::{FullTextParams, FullTextQuery, QueryAst}; | ||
use crate::OneFieldMap; | ||
|
||
/// `MatchBoolPrefixQuery` as defined in | ||
/// <https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-bool-prefix-query.html> | ||
#[derive(Deserialize, Clone, Eq, PartialEq, Debug)] | ||
#[serde( | ||
from = "OneFieldMap<MatchQueryParamsForDeserialization>", | ||
into = "OneFieldMap<MatchQueryParams>" | ||
)] | ||
pub(crate) struct MatchBoolPrefixQuery { | ||
pub(crate) field: String, | ||
pub(crate) params: MatchQueryParams, | ||
} | ||
|
||
impl ConvertableToQueryAst for MatchBoolPrefixQuery { | ||
fn convert_to_query_ast(self) -> anyhow::Result<QueryAst> { | ||
let full_text_params = FullTextParams { | ||
tokenizer: None, | ||
mode: crate::query_ast::FullTextMode::BoolPrefix { | ||
operator: self.params.operator, | ||
max_expansions: default_max_expansions(), | ||
}, | ||
zero_terms_query: self.params.zero_terms_query, | ||
}; | ||
Ok(QueryAst::FullText(FullTextQuery { | ||
field: self.field, | ||
text: self.params.query, | ||
params: full_text_params, | ||
})) | ||
} | ||
} | ||
|
||
impl From<OneFieldMap<MatchQueryParamsForDeserialization>> for MatchBoolPrefixQuery { | ||
fn from(match_query_params: OneFieldMap<MatchQueryParamsForDeserialization>) -> Self { | ||
let OneFieldMap { field, value } = match_query_params; | ||
MatchBoolPrefixQuery { | ||
field, | ||
params: value.inner, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.