diff --git a/backend/app/services/search_engine.py b/backend/app/services/search_engine.py index d36151a..f9d9661 100644 --- a/backend/app/services/search_engine.py +++ b/backend/app/services/search_engine.py @@ -613,7 +613,7 @@ class AdvancedSearchEngine: term_conditions: list = [] # 1. 字段级搜索 [TI] [AB] [TIAB] [AU] [TA] [LA] [VI] [IP] [PG] [LID] - field_combine = or_ if pp.boolean_operator == "or" else and_ + field_combine = or_ if pp.boolean_operator in ("or", "mixed") else and_ field_map = { "title": pp.title_terms, "abstract": pp.abstract_terms, @@ -949,10 +949,10 @@ class AdvancedSearchEngine: # 将 term_conditions 加入 conditions if term_conditions: - if pp.boolean_operator == "or": + if pp.boolean_operator in ("or", "mixed"): from sqlalchemy.sql.elements import UnaryExpression from sqlalchemy.sql import operators as _sa_ops - # OR 模式下 NOT 项应独立 AND(PubMed: A OR B NOT C = (A OR B) AND NOT C) + # OR/mixed 模式下 NOT 项应独立 AND(PubMed: A OR B NOT C = (A OR B) AND NOT C) pos_conds = [c for c in term_conditions if not (isinstance(c, UnaryExpression) and c.modifier == _sa_ops.inv)] neg_conds = [c for c in term_conditions