From 30714c67864e1190144244bd9ed19e8bd040aea3 Mon Sep 17 00:00:00 2001
From: Jeremiah Via <jeremiah.via@nytimes.com>
Date: Fri, 19 Jan 2024 13:07:17 -0800
Subject: [PATCH 1/3] Upgrade to [org.querqy/querqy-core "3.14.0"]

---
 project.clj                            | 2 +-
 src/com/nytimes/querqy/commonrules.clj | 6 ++++--
 src/com/nytimes/querqy/model.clj       | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/project.clj b/project.clj
index b45df65..861f80d 100644
--- a/project.clj
+++ b/project.clj
@@ -21,7 +21,7 @@
 
   :dependencies
   [[org.clojure/clojure "1.11.1"]
-   [org.querqy/querqy-core "3.12.0"]]
+   [org.querqy/querqy-core "3.14.0"]]
 
   :repl-options {:init-ns com.nytimes.querqy}
 
diff --git a/src/com/nytimes/querqy/commonrules.clj b/src/com/nytimes/querqy/commonrules.clj
index e2fbf34..970da84 100644
--- a/src/com/nytimes/querqy/commonrules.clj
+++ b/src/com/nytimes/querqy/commonrules.clj
@@ -14,7 +14,7 @@
    (querqy.parser QuerqyParser)
    (querqy.rewrite RewriterFactory)
    (querqy.rewrite.commonrules CommonRulesRewriter LineParser QuerqyParserFactory SimpleCommonRulesParser WhiteSpaceQuerqyParserFactory)
-   (querqy.rewrite.commonrules.model BoostInstruction BoostInstruction$BoostDirection DeleteInstruction FilterInstruction Instructions SynonymInstruction TrieMapRulesCollectionBuilder)
+   (querqy.rewrite.commonrules.model BoostInstruction BoostInstruction$BoostDirection BoostInstruction$BoostMethod DeleteInstruction FilterInstruction Instructions SynonymInstruction TrieMapRulesCollectionBuilder)
    (querqy.rewrite.commonrules.select SelectionStrategyFactory)
    (querqy.rewrite.commonrules.select.booleaninput BooleanInputParser)
    (querqy.rewrite.commonrules.select.booleaninput.model BooleanInputElement BooleanInputElement$Type BooleanInputLiteral)))
@@ -62,7 +62,8 @@
                        ^Reader stream
                        ^boolean boolean-input
                        ^QuerqyParserFactory parser
-                       ^boolean ignore-case)]
+                       ^boolean ignore-case
+                       BoostInstruction$BoostMethod/ADDITIVE)]
      (.parse rules-parser))))
 
 (extend-protocol CommonRulesRewriterBuilder
@@ -135,6 +136,7 @@
         DOWN BoostInstruction$BoostDirection/DOWN]
     (BoostInstruction. (parse-query query)
                        (if (>= boost 0) UP DOWN)
+                       BoostInstruction$BoostMethod/ADDITIVE
                        (abs boost))))
 
 (defn filter
diff --git a/src/com/nytimes/querqy/model.clj b/src/com/nytimes/querqy/model.clj
index 9bdd4e9..cb59a12 100644
--- a/src/com/nytimes/querqy/model.clj
+++ b/src/com/nytimes/querqy/model.clj
@@ -228,7 +228,7 @@
             :or   {boost-up   []
                    boost-down []
                    filter     []}}]
-  (ExpandedQuery. query filter boost-up boost-down))
+  (ExpandedQuery. query filter boost-up boost-down []))
 
 (defn expanded?
   [obj]

From 17f2652a88c7a5286a28253177964471c52d7055 Mon Sep 17 00:00:00 2001
From: Jeremiah Via <jeremiah.via@nytimes.com>
Date: Fri, 19 Jan 2024 13:13:20 -0800
Subject: [PATCH 2/3] Upgrade to [org.querqy/querqy-core "3.15.0"]

---
 project.clj                            |  2 +-
 src/com/nytimes/querqy/commonrules.clj | 86 ++++++++++++++++++++------
 src/com/nytimes/querqy/context.clj     |  7 +--
 src/com/nytimes/querqy/protocols.clj   | 10 +--
 4 files changed, 75 insertions(+), 30 deletions(-)

diff --git a/project.clj b/project.clj
index 861f80d..bbf7b7c 100644
--- a/project.clj
+++ b/project.clj
@@ -21,7 +21,7 @@
 
   :dependencies
   [[org.clojure/clojure "1.11.1"]
-   [org.querqy/querqy-core "3.14.0"]]
+   [org.querqy/querqy-core "3.15.0"]]
 
   :repl-options {:init-ns com.nytimes.querqy}
 
diff --git a/src/com/nytimes/querqy/commonrules.clj b/src/com/nytimes/querqy/commonrules.clj
index 970da84..12958aa 100644
--- a/src/com/nytimes/querqy/commonrules.clj
+++ b/src/com/nytimes/querqy/commonrules.clj
@@ -7,17 +7,45 @@
    [com.nytimes.querqy.model :as model]
    [com.nytimes.querqy.parser :as parser])
   (:import
-   (java.io Reader)
-   (java.net URL)
-   (java.util List UUID)
-   (querqy.model Input Input$BooleanInput Input$SimpleInput)
-   (querqy.parser QuerqyParser)
-   (querqy.rewrite RewriterFactory)
-   (querqy.rewrite.commonrules CommonRulesRewriter LineParser QuerqyParserFactory SimpleCommonRulesParser WhiteSpaceQuerqyParserFactory)
-   (querqy.rewrite.commonrules.model BoostInstruction BoostInstruction$BoostDirection BoostInstruction$BoostMethod DeleteInstruction FilterInstruction Instructions SynonymInstruction TrieMapRulesCollectionBuilder)
-   (querqy.rewrite.commonrules.select SelectionStrategyFactory)
-   (querqy.rewrite.commonrules.select.booleaninput BooleanInputParser)
-   (querqy.rewrite.commonrules.select.booleaninput.model BooleanInputElement BooleanInputElement$Type BooleanInputLiteral)))
+   (java.io
+    Reader)
+   (java.net
+    URL)
+   (java.util
+    List
+    UUID)
+   (querqy.model
+    Input
+    Input$BooleanInput
+    Input$SimpleInput)
+   (querqy.parser
+    QuerqyParser)
+   (querqy.rewrite
+    RewriterFactory)
+   (querqy.rewrite.commonrules
+    CommonRulesRewriter
+    LineParser
+    QuerqyParserFactory
+    SimpleCommonRulesParser
+    WhiteSpaceQuerqyParserFactory)
+   (querqy.rewrite.commonrules.model
+    BoostInstruction
+    BoostInstruction$BoostDirection
+    BoostInstruction$BoostMethod
+    DeleteInstruction
+    FilterInstruction
+    InstructionDescription
+    Instructions
+    SynonymInstruction
+    TrieMapRulesCollectionBuilder)
+   (querqy.rewrite.commonrules.select
+    SelectionStrategyFactory)
+   (querqy.rewrite.commonrules.select.booleaninput
+    BooleanInputParser)
+   (querqy.rewrite.commonrules.select.booleaninput.model
+    BooleanInputElement
+    BooleanInputElement$Type
+    BooleanInputLiteral)))
 
 (set! *warn-on-reflection* true)
 
@@ -78,6 +106,15 @@
 
 (defrecord Rule [input instructions])
 
+(defn- description
+  ^InstructionDescription
+  [& {:keys [^String type, param, ^String value]}]
+  (cond-> (InstructionDescription/builder)
+    (some? type) (.typeName type)
+    (some? param) (.param param)
+    (some? value) (.value value)
+    :finally (.build)))
+
 (defn match*
   "Create a "
   [head & tail]
@@ -114,7 +151,9 @@
 
 (defn delete
   [string]
-  (DeleteInstruction. (parse-string string)))
+  (DeleteInstruction.
+   (parse-string string)
+   (description {:type "delete", :value string})))
 
 (defn synonym?
   [obj]
@@ -123,9 +162,12 @@
 (defn synonym
   "Create a synonym instruction."
   ([string]
-   (SynonymInstruction. (parse-string string)))
+   (synonym 1.0 string))
   ([boost string]
-   (SynonymInstruction. (parse-string string) boost)))
+   (SynonymInstruction.
+    (parse-string string)
+    boost
+    (description {:type "synonym", :param boost, :value string}))))
 
 (defn boost
   "Boost a matching term or query."
@@ -134,15 +176,19 @@
     (throw (IllegalArgumentException. "Cannot boost by 0")))
   (let [UP   BoostInstruction$BoostDirection/UP
         DOWN BoostInstruction$BoostDirection/DOWN]
-    (BoostInstruction. (parse-query query)
-                       (if (>= boost 0) UP DOWN)
-                       BoostInstruction$BoostMethod/ADDITIVE
-                       (abs boost))))
+    (BoostInstruction.
+     (parse-query query)
+     (if (>= boost 0) UP DOWN)
+     BoostInstruction$BoostMethod/ADDITIVE
+     (abs boost)
+     (description {:type "boost", :param boost, :value (pr-str query)}))))
 
 (defn filter
   "Add a filter to the query."
   [query]
-  (FilterInstruction. (parse-query query)))
+  (FilterInstruction.
+   (parse-query query)
+   (description {:type "filter", :value (pr-str query)})))
 
 ;;; match impl
 
@@ -206,4 +252,4 @@
           (.addRule rules-builder input literal)))
 
       ;;
-      (rewriter-factory (.build rules-builder)))))
+      (rewriter-factory (.build rules-builder)))))
\ No newline at end of file
diff --git a/src/com/nytimes/querqy/context.clj b/src/com/nytimes/querqy/context.clj
index 765f3be..d3ad7d9 100644
--- a/src/com/nytimes/querqy/context.clj
+++ b/src/com/nytimes/querqy/context.clj
@@ -1,7 +1,7 @@
 (ns com.nytimes.querqy.context
   (:import
    (java.util Optional)
-   (querqy.rewrite SearchEngineRequestAdapter)))
+   (querqy.rewrite RewriteLoggingConfig SearchEngineRequestAdapter)))
 
 (defn optional
   ([] (Optional/empty))
@@ -18,12 +18,11 @@
   (getFloatRequestParam [_ k] (some-> (get params k) float optional))
   (getDoubleRequestParam [_ k] (some-> (get params k) double optional))
   (isDebugQuery [_] debug?)
-  (getInfoLoggingContext [_] (optional)))
+  (getRewriteLoggingConfig [_] (RewriteLoggingConfig/off)))
 
 (def empty-context
   (map->Context
    {:chain   []
     :debug?  false
     :params  {}
-    :context {}}))
-
+    :context {}}))
\ No newline at end of file
diff --git a/src/com/nytimes/querqy/protocols.clj b/src/com/nytimes/querqy/protocols.clj
index ee3ebbf..162dbc0 100644
--- a/src/com/nytimes/querqy/protocols.clj
+++ b/src/com/nytimes/querqy/protocols.clj
@@ -3,7 +3,7 @@
    [com.nytimes.querqy.context :as context])
   (:import
    (querqy.model ExpandedQuery Query)
-   (querqy.rewrite ContextAwareQueryRewriter RewriteChain RewriterFactory SearchEngineRequestAdapter)))
+   (querqy.rewrite QueryRewriter RewriteChain RewriterFactory SearchEngineRequestAdapter)))
 
 (defprotocol Parser
   (parse ^Query [this ^String string]
@@ -21,19 +21,19 @@
 ;; Some default Rewriter implementations for the Querqy classes.
 
 (extend-protocol Rewriter
-  ContextAwareQueryRewriter
+  QueryRewriter
   (rewrite
     ([this query]
      (rewrite this query context/empty-context))
     ([this query context]
-     (.rewrite this query context)))
+     (some-> (.rewrite this query context) (.getExpandedQuery))))
 
   RewriteChain
   (rewrite
     ([this query]
      (rewrite this query context/empty-context))
     ([this query context]
-     (.rewrite this query context)))
+     (some-> (.rewrite this query context) (.getExpandedQuery))))
 
   RewriterFactory
   (rewrite
@@ -47,4 +47,4 @@
 
 (defprotocol Emitter
   (emit [this query opts]
-    "Emit a system-specific query for a given `querqy.model.ExpandedQuery`"))
+    "Emit a system-specific query for a given `querqy.model.ExpandedQuery`"))
\ No newline at end of file

From 266ebbcdd12c338557db93791826751969c93d50 Mon Sep 17 00:00:00 2001
From: Jeremiah Via <jeremiah.via@nytimes.com>
Date: Fri, 19 Jan 2024 13:20:40 -0800
Subject: [PATCH 3/3] Upgrade to [org.querqy/querqy-core "3.16.0"]

---
 project.clj | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/project.clj b/project.clj
index bbf7b7c..eab0afd 100644
--- a/project.clj
+++ b/project.clj
@@ -21,7 +21,7 @@
 
   :dependencies
   [[org.clojure/clojure "1.11.1"]
-   [org.querqy/querqy-core "3.15.0"]]
+   [org.querqy/querqy-core "3.16.0"]]
 
   :repl-options {:init-ns com.nytimes.querqy}