Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit ac9e8a1bea1c3b4090e58f26bddb1bb956008cb6 0 parents
Thijs Oppermann authored
2  .gitignore
@@ -0,0 +1,2 @@
+*.~*~
+*.fasl
5 README
@@ -0,0 +1,5 @@
+Common Lisp Sphinx Search API
+=============================
+
+
+
92 constants.lisp
@@ -0,0 +1,92 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package #:com.oppermannen.sphinx-search-api)
+
+
+;; known searchd commands
+(defconstant +searchd-command-search+ 0)
+(defconstant +searchd-command-excerpt+ 1)
+(defconstant +searchd-command-update+ 2)
+(defconstant +searchd-command-keywords+ 3)
+(defconstant +searchd-command-persist+ 4)
+
+;; current client-side command implementation versions
+(defconstant +ver-command-search+ #x116)
+(defconstant +ver-command-excerpt+ #x100)
+(defconstant +ver-command-update+ #x101)
+(defconstant +ver-command-keywords+ #x100)
+
+;; known searchd status codes
+(defconstant +searchd-ok+ 0)
+(defconstant +searchd-error+ 1)
+(defconstant +searchd-retry+ 2)
+(defconstant +searchd-warning+ 3)
+
+;; known match modes
+(defconstant +sph-match-all+ 0)
+(defconstant +sph-match-any+ 1)
+(defconstant +sph-match-phrase+ 2)
+(defconstant +sph-match-boolean+ 3)
+(defconstant +sph-match-extended+ 4)
+(defconstant +sph-match-fullscan+ 5)
+(defconstant +sph-match-extended2+ 6)
+
+;; known ranking modes (extended2 mode only)
+(defconstant +sph-rank-proximity-bm25+ 0) ;; default mode, phrase proximity major factor and BM25 minor one
+(defconstant +sph-rank-bm25+ 1) ;; statistical mode, BM25 ranking only (faster but worse quality)
+(defconstant +sph-rank-none+ 2) ;; no ranking, all matches get a weight of 1
+(defconstant +sph-rank-wordcount+ 3) ;; simple word-count weighting, rank is a weighted sum of per-field keyword occurence counts
+
+;; known sort modes
+(defconstant +sph-sort-relevance+ 0)
+(defconstant +sph-sort-attr-desc+ 1)
+(defconstant +sph-sort-attr-asc+ 2)
+(defconstant +sph-sort-time-segments+ 3)
+(defconstant +sph-sort-extended+ 4)
+(defconstant +sph-sort-expr+ 5)
+
+;; known filter types
+(defconstant +sph-filter-values+ 0)
+(defconstant +sph-filter-range+ 1)
+(defconstant +sph-filter-floatrange+ 2)
+
+;; known attribute types
+(defconstant +sph-attr-none+ 0)
+(defconstant +sph-attr-integer+ 1)
+(defconstant +sph-attr-timestamp+ 2)
+(defconstant +sph-attr-ordinal+ 3)
+(defconstant +sph-attr-bool+ 4)
+(defconstant +sph-attr-float+ 5)
+(defconstant +sph-attr-bigint+ 6)
+
+;; SPH_ATTR_MULTI = 0X40000000L
+
+(defconstant +sph-attr-multi+ #x40000000)
+
+
+;; SPH_ATTR_TYPES = (SPH_ATTR_NONE,
+;; SPH_ATTR_INTEGER,
+;; SPH_ATTR_TIMESTAMP,
+;; SPH_ATTR_ORDINAL,
+;; SPH_ATTR_BOOL,
+;; SPH_ATTR_FLOAT,
+;; SPH_ATTR_BIGINT,
+;; SPH_ATTR_MULTI)
+
+(defconstant +sph-attr-types+ (list +sph-attr-none+
+ +sph-attr-integer+
+ +sph-attr-timestamp+
+ +sph-attr-ordinal+
+ +sph-attr-bool+
+ +sph-attr-float+
+ +sph-attr-bigint+
+ +sph-attr-multi+))
+
+;; known grouping functions
+(defconstant +sph-groupby-day+ 0)
+(defconstant +sph-groupby-week+ 1)
+(defconstant +sph-groupby-month+ 2)
+(defconstant +sph-groupby-year+ 3)
+(defconstant +sph-groupby-attr+ 4)
+(defconstant +sph-groupby-attrpair+ 5)
+
10 package.lisp
@@ -0,0 +1,10 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package #:cl-user)
+
+
+(defpackage #:com.oppermannen.sphinx-search-api
+ (:nicknames "sphinx-search-api")
+ (:use :cl)
+ (:export #:bla))
+
23 sphinx-search-api-config.asd
@@ -0,0 +1,23 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package :cl-user)
+
+(defpackage #:com.oppermannen.sphinx-search-api-test-asd
+ (:use :cl :asdf))
+
+(in-package :com.oppermannen.sphinx-search-api-test-asd)
+
+
+(defsystem #:sphinx-search-api-test
+ :name "SPHINX-SEARCH-API-TEST"
+ :version "0.0.1"
+ :maintainer "M.L. Oppermann <M.L.Oppermann@gmail.com>"
+ :author "M.L. Oppermann <M.L.Oppermann@gmail.com>"
+ :licence "To be determined"
+ :description "Test suite for SPHINX-SEARCH-API"
+ :long-description "this is the test suite system for SPHINX-SEARCH-API"
+ :components ((:module "test"
+ :components ((:file "package")
+ (:file "test" :depends-on ("package")))))
+ :depends-on (:sphinx-search-api))
+
5 sphinx-search-api-config.lisp
@@ -0,0 +1,5 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package #:com.oppermannen.sphinx-search-api)
+
+(defparameter *debug* t)
24 sphinx-search-api.asd
@@ -0,0 +1,24 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package #:cl-user)
+
+(defpackage #:com.oppermannen.sphinx-search-api-asd
+ (:use :cl :asdf))
+
+
+(in-package #:com.oppermannen.sphinx-search-api-asd)
+
+(defsystem #:sphinx-search-api
+ :name "SPHINX-SEARCH-API"
+ :version "0.0.1"
+ :maintainer "M.L. Oppermann <M.L.Oppermann@gmail.com>"
+ :author "M.L. Oppermann <M.L.Oppermann@gmail.com>"
+ :licence "To be determined"
+ :description "Classifier based on bayes theorem"
+ :long-description "SPHINX-SEARCH-API is the Common Lisp connection layer to Sphinx Search <http://sphinxsearch.com/>"
+ :serial t
+ :components ((:file "package")
+ (:file "sphinx-search-api-config")
+ (:file "constants")
+ (:file "sphinx-search-api"))
+ :depends-on (:cl-pack))
162 sphinx-search-api.lisp
@@ -0,0 +1,162 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package #:com.oppermannen.sphinx-search-api)
+
+
+(defclass sphinx-client ()
+ ((host
+ :accessor host
+ :initarg :host
+ :initform "localhost"
+ :documentation "searchd host (default is 'localhost')")
+ (port
+ :accessor port
+ :initarg :port
+ :initform 3312
+ :documentation "searchd port (default is 3312)")
+ (path
+ :accessor path
+ :initarg :path
+ :initform ()
+ :documentation "searchd unix-domain socket path")
+ (socket
+ :accessor socket
+ :initarg :socket
+ :initform ()
+ :documentation "searchd unix-domain socket")
+ (offset
+ :accessor offset
+ :initarg :offset
+ :initform 0
+ :documentation "how much records to seek from result-set start (default is 0)")
+ (limit
+ :accessor limit
+ :initarg :limit
+ :initform 20
+ :documentation "how much records to return from result-set starting at offset (default is 20)")
+ (mode
+ :accessor mode
+ :initarg :mode
+ :initform +sph-match-all+
+ :documentation "query matching mode (default is +sph-match-all+)")
+ (weights
+ :accessor weights
+ :initarg :weights
+ :initform ()
+ :documentation "per-field weights (default is 1 for all fields)")
+ (sort
+ :accessor sort
+ :initarg :sort
+ :initform +sph-sort-relevance+
+ :documentation "match sorting mode (default is +sph-sort-relevance+)")
+ (sortby
+ :accessor sortby
+ :initarg :sortby
+ :initform ""
+ :documentation "attribute to sort by (defualt is '')")
+ (min_id
+ :accessor min_id
+ :initarg :min_id
+ :initform 0
+ :documentation "min ID to match (default is 0)")
+ (max_id
+ :accessor max_id
+ :initarg :max_id
+ :initform ()
+ :documentation "max ID to match (default is max value for uint on system)")
+ (filters
+ :accessor filters
+ :initarg :filters
+ :initform ()
+ :documentation "search filters")
+ (groupby
+ :accessor groupby
+ :initarg :groupby
+ :initform ""
+ :documentation "group-by attribute name")
+ (groupfunc
+ :accessor groupfunc
+ :initarg :groupfunc
+ :initform +sph-groupby-day+
+ :documentation "group-by function (to pre-process group-by attribute value with; default +sph-groupby-day+)")
+ (groupsort
+ :accessor groupsort
+ :initarg :groupsort
+ :initform "@group desc"
+ :documentation "group-by sorting clause (to sort groups in result set with; default '@group desc')")
+ (groupdistinct
+ :accessor groupdistinct
+ :initarg :groupdistinct
+ :initform ""
+ :documentation "group-by count-distinct attribute")
+ (maxmatches
+ :accessor maxmatches
+ :initarg :maxmatches
+ :initform 1000
+ :documentation "max matches to retrieve (default is 1000)")
+ (cutoff
+ :accessor cutoff
+ :initarg :cutoff
+ :initform ()
+ :documentation "cutoff to stop searching at")
+ (retrycount
+ :accessor retrycount
+ :initarg :retrycount
+ :initform 0
+ :documentation "distributed retry count")
+ (retrydelay
+ :accessor retrydelay
+ :initarg :retrydelay
+ :initform 0
+ :documentation "distributed retry delay")
+ (anchor
+ :accessor anchor
+ :initarg :anchor
+ :initform ()
+ :documentation "geographical anchor point")
+ (indexweights
+ :accessor indexweights
+ :initarg :indexweights
+ :initform ()
+ :documentation "per-index weights")
+ (ranker
+ :accessor ranker
+ :initarg :ranker
+ :initform +sph-rank-proximity-bm25+
+ :documentation "ranking mode (default is +sph-rank-proximity-bm25+)")
+ (maxquerytime
+ :accessor maxquerytime
+ :initarg :maxquerytime
+ :initform 0
+ :documentation "max query time, milliseconds (default is 0, do not limit)")
+ (fieldweights
+ :accessor fieldweights
+ :initarg :fieldweights
+ :initform ()
+ :documentation "per-field-name weights")
+ (overrides
+ :accessor overrides
+ :initarg :overrides
+ :initform ()
+ :documentation "per-query attribute values overrides")
+ (select
+ :accessor select
+ :initarg :select
+ :initform "*"
+ :documentation "select-list (attributes or expressions, with optional aliases)")
+ (last-error
+ :accessor last-error
+ :initarg :last-error
+ :initform ""
+ :documentation "last error message")
+ (last-warning
+ :accessor last-warning
+ :initarg :last-warning
+ :initform ""
+ :documentation "last warning message")
+ (reqs
+ :accessor reqs
+ :initarg :reqs
+ :initform ()
+ :documentation "requests array for multi-query"))
+
9 test/package.lisp
@@ -0,0 +1,9 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package #:cl-user)
+
+(defpackage #:com.oppermannen.bayes-classifier-test
+ (:nicknames :bayes-classifier-test)
+ (:use :cl
+ :fiveam
+ :com.oppermannen.bayes-classifier))
9 test/test.lisp
@@ -0,0 +1,9 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package #:com.oppermannen.bayes-classifier-test)
+
+
+(5am:def-suite bayes-classifier-tests
+ :description "Top-level test suite for bayes-classifier")
+
+(5am:in-suite bayes-classifier-tests)
Please sign in to comment.
Something went wrong with that request. Please try again.