anchor.diff:      :accessor filters
       :initarg :filters
       :initform ()
  -    :documentation "search filters")
  -   (groupby
  -    :accessor groupby
  -    :initarg :groupby
  +    :documentation "search filters; a list of hashes")
  +   (group-by
  +    :accessor group-by
  +    :initarg :group-by
       :initform ""
       :documentation "group-by attribute name")
  -   (groupfunc
  -    :accessor groupfunc
  -    :initarg :groupfunc
  +   (group-function
  +    :accessor group-function
  +    :initarg :group-function
       :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
  +   (group-sort
  +    :accessor group-sort
  +    :initarg :group-sort
       :initform "@group desc"
       :documentation "group-by sorting clause (to sort groups in result set with; default '@group desc')")
  -   (groupdistinct
  -    :accessor groupdistinct
  -    :initarg :groupdistinct
  +   (group-distinct
  +    :accessor group-distinct
  +    :initarg :group-distinct
       :initform ""
       :documentation "group-by count-distinct attribute")
  -   (maxmatches
  -    :accessor maxmatches
  -    :initarg :maxmatches
  +   (max-matches
  +    :accessor max-matches
  +    :initarg :max-matches
       :initform 1000
       :documentation "max matches to retrieve (default is 1000)")
      (cutoff
  
positive.code: 
  
  (defclass sphinx-client ()
    ((sphinx-host
      :accessor sphinx-host
      :initarg :host
      :initform "localhost"
      :documentation "searchd host (default is 'localhost')")
     (sphinx-port
      :accessor sphinx-port
      :initarg :port
      :initform 3312
      :documentation "searchd port (default is 3312)")
     (sphinx-path
      :accessor sphinx-path
      :initarg :path
      :initform ()
      :documentation "searchd unix-domain socket path")
     (sphinx-socket
      :accessor sphinx-socket
      :initarg :socket
      :initform ()
      :documentation "searchd unix-domain socket")
  
negative.code:   (setf (offset client) offset)
    (setf (limit client) limit)
    (when (> max 0)
      (setf (max-matches client) max))
    (when (and cutoff (>= cutoff 0))
      (setf (cutoff client) cutoff)))
  
  
  (defmethod add-query ((client sphinx-client) &key query (index "*") (comment ""))
   (let ((req (concatenate 'string
                            (pack "NNNNN" (offset client) (limit client) (mode client) (ranker client) (sort-mode client))
                            (pack "N/a*" (sort-by client))
                            (pack "N/a*" query)
                            (pack "N*" (length (weights client)) (weights client))
                            (pack "N/a*" index)
                            (pack "N" 1) (pack "Q>" (min-id client)) (pack "Q>" (max-id client))
                            (pack "N" (length (filters client)))
                            (map #'(lambda (filter)
                                     (concatenate 'string
                                                  (pack "N/a*" (gethash 'attr filter))
                                                  (let ((type (gethash 'type filter)))
                                                    (concatenate 'string
                                                                 (pack "N" type)
                                                                 (cond ((eql type +sph-filter-values+)
                                                                        (pack-array-signed-quads (get-hash 'values filter)))
                                                                       ((eql type +sph-filter-range+)
                                                                        (concatenate 'string (pack "q>" (get-hash 'min filter))
                                                                                             (pack "q>" (get-hash 'max filter))))
                                                                       ((eql type +sph-filter-floatrange+)
                                                                        (concatenate 'string (pack-float (get-hash 'min filter))
                                                                                             (pack-float (get-hash 'max filter))))
                                                                       (t
                                                                        (error "Unhandled filter type ~S" type)))
                                                                 (pack "N" (get-hash 'exclude filter))))))
                                 (filters client))
                            (pack "NN/a*" (group-function client) (group-by client))
                            (pack "N" (max-matches client))
                            (pack "N/a*" (group-sort client))
                            (pack "NNN" (cutoff client) (retry-count client) (retry-delay client))
                            (pack "N/a*" (group-distinct client))
                            (cond ((anchor client)
                                   (concatenate 'string
                                                (pack "N/a*" (first (anchor client)))
                                                (pack "N/a*" (third (anchor client)))
                                                (pack-float (second (anchor client)))
                                                (pack-float (last (anchor client)))))
                                  (t
                                   (pack "N" 0)))
  
  
  
  
  (defun pack-array-signed-quads (values-list)
    (concatenate 'string
                 (pack "N" (length values-list))
                 (map #'(lambda (value)
                          (pack "q>" value)) values-list)))
  
  (defun pack-float (float-value)
    (pack "N" (unpack "L*" (pack "f" float-value))))
  
  
  
  