From 950b25d95d4d2514f9aab6c387b2c246bf96a4c8 Mon Sep 17 00:00:00 2001 From: Jeremiah Via Date: Fri, 19 Jan 2024 13:39:07 -0800 Subject: [PATCH] Prepare for 0.8.0 --- project.clj | 2 +- src/com/nytimes/querqy/commonrules.clj | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/project.clj b/project.clj index eab0afd..47e56fd 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject com.nytimes/querqy-clj "0.7.1-SNAPSHOT" +(defproject com.nytimes/querqy-clj "0.8.0-SNAPSHOT" :description "Querqy in Clojure" :url "https://github.com/nytimes/querqy-clj" diff --git a/src/com/nytimes/querqy/commonrules.clj b/src/com/nytimes/querqy/commonrules.clj index 12958aa..9eef674 100644 --- a/src/com/nytimes/querqy/commonrules.clj +++ b/src/com/nytimes/querqy/commonrules.clj @@ -150,6 +150,8 @@ (instance? DeleteInstruction obj)) (defn delete + "Delete text from a matched query. This is useful for removing unhelpful + search terms from the query." [string] (DeleteInstruction. (parse-string string) @@ -160,7 +162,12 @@ (instance? SynonymInstruction obj)) (defn synonym - "Create a synonym instruction." + "Create a synonym for the matched text. + + ```clojure + (match \"chickpeas\" + (synonym \"garbanzo beans\")) + ```" ([string] (synonym 1.0 string)) ([boost string] @@ -170,7 +177,14 @@ (description {:type "synonym", :param boost, :value string})))) (defn boost - "Boost a matching term or query." + "Boost a matching term or query. + + ```clojure + ;; Boost recipes which take less than 30 minutes when queries + ;; match quick and recipe or recipes. + (match (and \"quick\" (or \"recipe\" \"recipes\") + (boost 10 {:range {:minutes {:lte 30}}})) + ```" [boost query] (when (zero? boost) (throw (IllegalArgumentException. "Cannot boost by 0"))) @@ -184,7 +198,12 @@ (description {:type "boost", :param boost, :value (pr-str query)})))) (defn filter - "Add a filter to the query." + "Add a filter to the query. Filters require a match on documents. + + ```clojure + (match \"by paul krugman\" + (filter {:term {:author \"Paul Krugman\"}})) + ```" [query] (FilterInstruction. (parse-query query)