diff --git a/README.md b/README.md index a47f6a6d..146f3260 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,9 @@ from clp_ffi_py.ir import ClpIrFileReader, Query, QueryBuilder # Create a QueryBuilder object to build the search query. query_builder: QueryBuilder = QueryBuilder() -# Add wildcard patterns to filter log messages: +# Add wildcard patterns to filter log messages.By default, the partial match +# will be executed. Please refer to the documents of `WildcardQuery` object for +# the difference between partial and full matches. query_builder.add_wildcard_query("uid=*,status=failed") query_builder.add_wildcard_query("UID=*,Status=KILLED", case_sensitive=True) diff --git a/src/clp_ffi_py/ir/native/PyQuery.cpp b/src/clp_ffi_py/ir/native/PyQuery.cpp index eb515eea..4629dfcb 100644 --- a/src/clp_ffi_py/ir/native/PyQuery.cpp +++ b/src/clp_ffi_py/ir/native/PyQuery.cpp @@ -109,7 +109,7 @@ auto serialize_wildcard_queries(std::vector const& wildcard_queri Py_ssize_t idx{0}; for (auto const& wildcard_query : wildcard_queries) { PyObjectPtr const wildcard_py_str_ptr{ - PyUnicode_FromString(wildcard_query.get_uncleaned_wildcard_query().c_str()) + PyUnicode_FromString(wildcard_query.get_original_query_string().c_str()) }; auto* wildcard_py_str{wildcard_py_str_ptr.get()}; if (nullptr == wildcard_py_str) { diff --git a/src/clp_ffi_py/ir/native/Query.hpp b/src/clp_ffi_py/ir/native/Query.hpp index 2901b60c..ac2f1097 100644 --- a/src/clp_ffi_py/ir/native/Query.hpp +++ b/src/clp_ffi_py/ir/native/Query.hpp @@ -28,21 +28,21 @@ class WildcardQuery { * @param partial_match Partial match indicator. */ WildcardQuery(std::string wildcard_query, bool case_sensitive, bool partial_match) - : m_uncleaned_wildcard_query(std::move(wildcard_query)), + : m_original_query_string(std::move(wildcard_query)), m_case_sensitive(case_sensitive), m_partial_match(partial_match) { if (partial_match) { m_wildcard_query = "*"; - m_wildcard_query += m_uncleaned_wildcard_query; + m_wildcard_query += m_original_query_string; m_wildcard_query += "*"; m_wildcard_query = clean_up_wildcard_search_string(m_wildcard_query); } else { - m_wildcard_query = clean_up_wildcard_search_string(m_uncleaned_wildcard_query); + m_wildcard_query = clean_up_wildcard_search_string(m_original_query_string); } } - [[nodiscard]] auto get_uncleaned_wildcard_query() const -> std::string const& { - return m_uncleaned_wildcard_query; + [[nodiscard]] auto get_original_query_string() const -> std::string const& { + return m_original_query_string; } [[nodiscard]] auto get_wildcard_query() const -> std::string const& { return m_wildcard_query; } @@ -52,7 +52,7 @@ class WildcardQuery { [[nodiscard]] auto is_partial_match() const -> bool { return m_partial_match; } private: - std::string m_uncleaned_wildcard_query; + std::string m_original_query_string; std::string m_wildcard_query; bool m_case_sensitive; bool m_partial_match;