Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost and explain #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Boost and explain #21

wants to merge 3 commits into from

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