diff --git a/src/metabase/search/postgres/index.clj b/src/metabase/search/postgres/index.clj index e80fd33ab6f0c18ebf1c5d722ae8f1d7b425b588..72139deb0eff9de5bb69cf4c9b9894f7ea973d08 100644 --- a/src/metabase/search/postgres/index.clj +++ b/src/metabase/search/postgres/index.clj @@ -179,6 +179,8 @@ (defn- process-phrase [word-or-phrase] ;; a phrase is quoted even if the closing quotation mark has not been typed yet (cond + ;; trailing quotation mark + (= word-or-phrase "\"") nil ;; quoted phrases must be matched sequentially (str/starts-with? word-or-phrase "\"") (as-> word-or-phrase <> @@ -206,6 +208,7 @@ (->> words-and-phrases (remove #{"and"}) (map process-phrase) + (remove str/blank?) (str/join " & "))) (defn- complete-last-word diff --git a/test/metabase/search/postgres/index_test.clj b/test/metabase/search/postgres/index_test.clj index 408431d5b3b09fa5a3ce0aef7085071c6d948737..b916f8336c2f79c1327df87b4fc186c07a760c20 100644 --- a/test/metabase/search/postgres/index_test.clj +++ b/test/metabase/search/postgres/index_test.clj @@ -190,7 +190,9 @@ (testing "unbalanced quotes" (is (= "'big' <-> 'data' & 'big' <-> 'mistake':*" - (search-expr "\"Big Data\" \"Big Mistake")))) + (search-expr "\"Big Data\" \"Big Mistake"))) + (is (= "'something'" + (search-expr "something \"")))) (is (= "'partial' <-> 'quoted' <-> 'and' <-> 'or' <-> '-split':*" (search-expr "\"partial quoted AND OR -split")))