Skip to content

Commit

Permalink
spi-search:fix split query ext.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljl committed Dec 3, 2024
1 parent bc25711 commit 55a795a
Show file tree
Hide file tree
Showing 3 changed files with 302 additions and 490 deletions.
22 changes: 1 addition & 21 deletions backend/spi/spi-search/src/dto/search_item_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,7 @@ pub struct AdvSearchItemQueryReq {
pub group_by_or: Option<bool>,
pub ext_by_or: Option<bool>,
// Extended filtering conditions
pub ext: Option<Vec<AdvBasicQueryCondInfo>>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object))]
pub struct AdvBasicQueryCondInfo {
pub in_ext: Option<bool>,
#[oai(validator(min_length = "1"))]
pub field: String,
pub op: BasicQueryOpKind,
pub value: Value,
}

impl From<AdvBasicQueryCondInfo> for BasicQueryCondInfo {
fn from(value: AdvBasicQueryCondInfo) -> Self {
Self {
field: value.field,
op: value.op,
value: value.value,
}
}
pub ext: Option<Vec<BasicQueryCondInfo>>,
}

#[derive(poem_openapi::Object, Serialize, Deserialize, Debug, Default, Clone)]
Expand Down
3 changes: 2 additions & 1 deletion backend/spi/spi-search/src/serv/es/search_es_item_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::dto::search_item_dto::{
};

use super::search_es_initializer;
const INNER_FIELD: [&str; 7] = ["key", "title", "content", "owner", "own_paths", "create_time", "update_time"];

fn format_index(req_index: &str, ext: &HashMap<String, String>) -> String {
if let Some(key_prefix) = common::get_isolation_flag_from_ext(ext) {
Expand Down Expand Up @@ -643,7 +644,7 @@ fn gen_query_dsl(search_req: &SearchItemSearchReq) -> TardisResult<String> {
for group_query in adv_query {
let mut group_query_q: Vec<Value> = vec![];
for cond_info in group_query.ext.clone().unwrap_or_default() {
let field = if cond_info.in_ext.unwrap_or(true) {
let field = if !INNER_FIELD.contains(&cond_info.field.clone().as_str()) {
format!("ext.{}", cond_info.field)
} else {
cond_info.field.clone()
Expand Down
Loading

0 comments on commit 55a795a

Please sign in to comment.