Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 80 lines (54 sloc) 2.305 kb
103a939 @weavejester Released 0.3.0
authored
1 Clucy
2 =====
3
565cf7d @weavejester Added README
authored
4 Clucy is a Clojure interface to [Lucene](http://lucene.apache.org/).
5
103a939 @weavejester Released 0.3.0
authored
6 Installation
7 ------------
8
9 To install Clucy, add the following dependency to your `project.clj`
10 file:
11
12 [clucy "0.3.0"]
13
565cf7d @weavejester Added README
authored
14 Usage
15 -----
16
17 To use Clucy, first require it:
18
19 (ns example
20 (:require [clucy.core :as clucy]))
21
22 Then create an index. You can use `(memory-index)`, which stores the search
23 index in RAM, or `(disk-index "/path/to/a-folder")`, which stores the index in
24 a folder on disk.
25
26 (def index (clucy/memory-index))
27
28 Next, add Clojure maps to the index:
29
30 (clucy/add index
31 {:name "Bob", :job "Builder"}
32 {:name "Donald", :job "Computer Scientist"})
33
b9499c9 Altered store functions to check metadata for information on which field...
Christopher Miles authored
34 You can remove maps just as easily:
35
36 (clucy/delete index
37 {:name "Bob", :job "Builder"})
38
565cf7d @weavejester Added README
authored
39 Once maps have been added, the index can be searched:
40
41 user=> (clucy/search index "bob" 10)
42 ({:name "Bob", :job "Builder"})
43
44 user=> (clucy/search index "scientist" 10)
45 ({:name "Donald", :job "Computer Scientist"})
b9499c9 Altered store functions to check metadata for information on which field...
Christopher Miles authored
46
47 You can search and remove all in one step. To remove all of the
48 scientists...
49
50 (clucy/search-and-delete index "job:scientist")
51
52 Storing Fields
53 --------------
54
55 By default all fields in a map are stored and indexed. If you would
56 like more fine-grained control over which fields are stored and index,
57 add this to the meta-data for your map.
58
59 (with-meta {:name "Stever", :job "Writer", :phone "555-212-0202"}
30bb844 @JulioBarros Minor typo fix in readme. :store should be :stored
JulioBarros authored
60 {:phone {:stored false}})
b9499c9 Altered store functions to check metadata for information on which field...
Christopher Miles authored
61
62 When the map above is saved to the index, the phone field will be
63 available for searching but will not be part of map in the search
64 results. This example is pretty contrived, this makes more sense when
65 you are indexing something large (like the full text of a long
66 article) and you don't want to pay the price of storing the entire
67 text in the index.
68
69 Default Search Field
70 --------------------
71
72 A field called "\_content" that contains all of the map's values is
30bb844 @JulioBarros Minor typo fix in readme. :store should be :stored
JulioBarros authored
73 stored in the index for each map (excluding fields with {:stored false}
b9499c9 Altered store functions to check metadata for information on which field...
Christopher Miles authored
74 in the map's metadata). This provides a default field to run all
75 searches against. Anytime you call the search function without
76 providing a default search field "\_content" is used.
77
78 This behavior can be disabled by binding *content* to false, you must
79 then specify the default search field with every search invocation.
Something went wrong with that request. Please try again.