weavejester/clucy — pull request #21 by ieure (2013-08-24 20:14:28+00:00)
Title: Boost and explain

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

Example of boosting:

```clojure
(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:

```clojure
(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}
```