{"id":17113713,"url":"https://github.com/federkasten/clucie","last_synced_at":"2025-05-10T23:15:28.144Z","repository":{"id":29187671,"uuid":"32718679","full_name":"federkasten/clucie","owner":"federkasten","description":"Clojure for the Lucene","archived":false,"fork":false,"pushed_at":"2023-01-24T14:23:47.000Z","size":108,"stargazers_count":59,"open_issues_count":2,"forks_count":9,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-10T23:15:21.715Z","etag":null,"topics":["clojure","fulltext-search","lucene"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/federkasten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-23T08:05:49.000Z","updated_at":"2024-05-31T07:52:13.000Z","dependencies_parsed_at":"2023-02-13T22:10:39.158Z","dependency_job_id":null,"html_url":"https://github.com/federkasten/clucie","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/federkasten%2Fclucie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/federkasten%2Fclucie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/federkasten%2Fclucie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/federkasten%2Fclucie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/federkasten","download_url":"https://codeload.github.com/federkasten/clucie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253492771,"owners_count":21916974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","fulltext-search","lucene"],"created_at":"2024-10-14T17:11:51.581Z","updated_at":"2025-05-10T23:15:28.097Z","avatar_url":"https://github.com/federkasten.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clucie\n\nClojure for the Lucene\n\n[![Build Status](https://travis-ci.org/federkasten/clucie.svg)](https://travis-ci.org/federkasten/clucie)\n\n[![Clojars Project](https://img.shields.io/clojars/v/clucie.svg)](https://clojars.org/clucie)\n\n# Usage\n\n## Simple Usage\n\n```clojure\n(require '[clucie.core :as core])\n(require '[clucie.analysis :as analysis])\n(require '[clucie.store :as store])\n\n(def analyzer (analysis/standard-analyzer))\n(def index-store (store/memory-store)) ; or (store/disk-store \"path/to/store\")\n\n(core/add! index-store\n           [{:number \"1\" :title \"Please Please Me\"}\n            {:number \"2\" :title \"With the Beatles\"}\n            {:number \"3\" :title \"A Hard Day's Night\"}\n            {:number \"4\" :title \"Beatles for Sale\"}\n            {:number \"5\" :title \"Help!\"}]\n           [:number :title]\n           analyzer)\n\n(core/search index-store\n             {:title \"Beatles\"}\n             10 ; max-num\n             analyzer\n             0 ; page\n             5) ; max-num-per-page\n\n;; =\u003e [{:number \"2\", :title \"With the Beatles\"} {:number \"4\", :title \"Beatles for Sale\"}]\n\n;; Phrase search\n(core/phrase-search index-store\n                    {:title \"beatles for\"}\n                    10\n                    analyzer\n                    0\n                    5)\n\n;; =\u003e [{:number \"4\", :title \"Beatles for Sale\"}]\n\n(core/phrase-search index-store\n                    {:title \"for beatles\"}\n                    10\n                    analyzer\n                    0\n                    5)\n\n;; =\u003e []\n\n;; AND search\n(core/search index-store\n             {:title [\"Beatles\" \"Sale\"]}\n             10\n             analyzer\n             0\n             5)\n\n;; =\u003e [{:number \"4\", :title \"Beatles for Sale\"}]\n\n;; AND search, across multiple keys\n(core/search index-store\n             [{:number \"4\"} {:title [\"Beatles\" \"Sale\"]}]\n             10\n             analyzer\n             0\n             5)\n\n;; =\u003e [{:number \"4\", :title \"Beatles for Sale\"}]\n\n(core/search index-store\n             [{:number \"3\"} {:title \"Beatles\"}]\n             10\n             analyzer\n             0\n             5)\n\n;; =\u003e []\n\n;; OR search\n(core/search index-store\n             {:title #{\"Beatles\" \"Please\"}}\n             10\n             analyzer\n             0\n             5)\n\n;; =\u003e [{:number \"1\", :title \"Please Please Me\"} {:number \"2\", :title \"With the Beatles\"} {:number \"4\", :title \"Beatles for Sale\"}]\n\n;; Get meta information\n(let [results (core/search index-store\n                           {:title #{\"Beatles\" \"Please\"}}\n                           10\n                           analyzer\n                           0\n                           5)]\n  ;; the total number of hits\n  (prn (:total-hits (meta results))) ; =\u003e 3\n  ;; scores\n  (prn (map #(:score (meta %)) results))) ; =\u003e (0.62241787 0.3930676 0.3930676)\n\n(store/close! index-store)\n```\n\nTo update index,\n\n```clojure\n(core/update! index-store\n              {:number \"5\" :title \"Help! (1965)\"}\n              [:number :title]\n              :number \"5\"\n              analyzer)\n```\n\nTo delete index,\n\n```clojure\n(core/delete! index-store :number \"5\" analyzer)\n```\n\n## CJK (Chinese, Japanese, and Korean) Support\n\n```clojure\n(def cjk-analyzer (analysis/cjk-analyzer))\n\n(def my-analyzer (analysis/analyzer-mapping (analysis/keyword-analyzer)\n                                            {:content cjk-analyzer}))\n\n(core/add! index-store\n           [{:key \"English\" :content \"Thank you\"}\n            {:key \"Chinese\" :content \"谢谢\"}\n            {:key \"Japanese\" :content \"ありがとう\"}\n            {:key \"Korean\" :content \"고마워요\"}]\n           [:key :content]\n           my-analyzer)\n```\n\n## Japanese Support (Kuromoji)\n\n```clojure\n(def kuromoji-analyzer (analysis/kuromoji-analyzer))\n\n(def my-analyzer (analysis/analyzer-mapping (analysis/keyword-analyzer)\n                                            {:content kuromoji-analyzer}))\n```\n\nTo tokenize,\n\n```clojure\n(let [text \"富士は日本一の山\"\n      user-dict nil\n      discard-punctuation? true\n      mode :normal ; :normal :extended :search\n      factory nil]\n  (analysis/kuromoji-tokenize text user-dict discard-punctuation? mode factory)) ; =\u003e (\"富士\" \"は\" \"日本一\" \"の\" \"山\")\n```\n\n## Custom analyzer\n\nTo build custom analyzer, you can use `build-analyzer` macro.\nThe following example builds an analyzer that normalizes input texts, splits texts into words, and generates n-grams.\n\n```clojure\n(analysis/build-analyzer\n  (JapaneseTokenizer. nil true JapaneseTokenizer$Mode/NORMAL)\n  :char-filter-factories [(ICUNormalizer2CharFilterFactory. (HashMap. {\"name\" \"nfkc\", \"mode\" \"compose\"}))]\n  :token-filters [(LowerCaseFilter.)\n                  (max-shingle/MaxShingleFilter. 3 \" \")])\n```\n\n## Reusing connections\n\nBy default, update/search functions create a new writer/reader each time,\nhowever, that is somewhat inefficient and not thread-safe. For high performance\nor concurrent processing, you can pass directly a writer/reader to them.\n\n```clojure\n(with-open [writer (store/store-writer index-store analyzer)]\n  (core/add! writer\n             [{:number \"1\" :title \"Please Please Me\"}\n              {:number \"2\" :title \"With the Beatles\"}]\n             [:number :title]))\n\n(with-open [reader (store/store-reader index-store)]\n  (core/search reader\n               {:title \"Beatles\"}\n               10\n               analyzer))\n```\n\n# Run tests\n\nRun `lein midje`.\n\n# Get coverage\n\nRun `lein cloverage` and see `target/coverage/index.html`.\n\n# License\n\nCopyright [Takashi AOKI][tak.sh] and other contributors.\n\nLicensed under the [Apache License, Version 2.0][apache-license-2.0].\n\n[tak.sh]: http://tak.sh\n[apache-license-2.0]: http://www.apache.org/licenses/LICENSE-2.0.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffederkasten%2Fclucie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffederkasten%2Fclucie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffederkasten%2Fclucie/lists"}