Skip to content

Boost and explain#21

Open
ieure wants to merge 3 commits intoweavejester:masterfrom
ieure:boost_and_explain
Open

Boost and explain#21
ieure wants to merge 3 commits intoweavejester:masterfrom
ieure:boost_and_explain

Conversation

@ieure
Copy link

@ieure ieure commented Aug 24, 2013

This adds support for per-field boost values (set in the document metadata) and query explanations.

Example of boosting:

(let [i (memory-index)]
      (add i
           (with-meta {:planet "Earth Mk. II" :designer "Slartibartfast"}
             {:name {:boost 0.0}})
           (with-meta {:planet "Earth" :designer "Slartibartfast"}
             {:name {:boost 1.0}}))
      (search i "Slartibartfast" 2)) ;; -> Earth

Example of explaining:

(let [i (memory-index)]
      (add i {:name "Miles" :age 36}
           {:name "Emily" :age 0.3}
           {:name "Joanna" :age 34}
           {:name "Melinda" :age 34}
           {:name "Mary" :age 48}
           {:name "Mary Lou" :age 39})
      (meta (first (search i "Miles" 10 :explain true))))

;; Output

{:children
 ({:children
   ({:children
     ({:description "idf(docFreq=1, maxDocs=6)",
       :value 2.0986123,
       :match? true}
      {:description "queryNorm", :value 0.47650534, :match? true}),
     :description "queryWeight, product of:",
     :value 0.99999994,
     :match? true}
    {:children
     ({:children
       ({:description "termFreq=1.0", :value 1.0, :match? true}),
       :description "tf(freq=1.0), with freq of:",
       :value 1.0,
       :match? true}
      {:description "idf(docFreq=1, maxDocs=6)",
       :value 2.0986123,
       :match? true}
      {:description "fieldNorm(doc=0)", :value 0.625, :match? true}),
     :description "fieldWeight in 0, product of:",
     :value 1.3116326,
     :match? true}),
   :description "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
   :value 1.3116325,
   :match? true}),
 :description
 "weight(_content:miles in 0) [DefaultSimilarity], result of:",
 :value 1.3116325,
 :match? true}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant