weavejester / clucy

Clojure interface to Lucene
Eclipse Public License 1.0
172 stars 58 forks source link

numeric value and multivalue fields support #22

Open yxzhang opened 11 years ago

yxzhang commented 11 years ago

just like :

Numeric Types

You can add maps with numeric value to the index:

    (clucy/add index
       {:name "Bob", :age (int 20)}
       {:name "Donald", :age (int 35)})

Once maps have been added, the index can be searched:

    user=> (binding [clucy/*numeric-hints* {"age" "int"}]
          (clucy/search index "age:20" 10))
    ({:age 20, :name "Bob"})

Or do range query just as :

    user=> (binding [clucy/*numeric-hints* {"age" "int"}]
          (clucy/search index "age:[32 TO 35]" 10))
    ({:age 35, :name "Donald"})

Numberic type can be one of int, long, double, float.

Multivalued Fields

You can use clojure collection to manage multivalued fields, eg.

    (clucy/add index
       {:name "Bob", :books ["Clojure Programming" "Clojure In Action"] }
        user=> (search index "books:action" 10)
       ({:name "Bob", :books ["Clojure Programming" "Clojure In Action"]})