anchor.diff:    (setf (offset client) offset)
     (setf (limit client) limit)
     (when (> max 0)
  -    (setf (maxmatches client) max))
  +    (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
  + (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*" (string-to-octets query))
  -                          (pack "N*" (length (weights client)) (weights client)))))
  -    req))
  -
  -
  +                          (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))))
  +
  +
  +
  
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:     :initarg :cutoff
      :initform ()
      :documentation "cutoff to stop searching at")
     (retry-count
      :accessor retry-count
      :initarg :retry-count
      :initform 0
      :documentation "distributed retry count")
     (retry-delay
      :accessor retry-delay
      :initarg :retry-delay
      :initform 0
      :documentation "distributed retry delay")
     (anchor
      :accessor anchor
      :initarg :anchor
      :initform ()
      :documentation "geographical anchor point; fixed length list with '(attrlat lat attrlon lon)")
     (index-weights
      :accessor index-weights
      :initarg :index-weights
      :initform ()
      :documentation "per-index weights")
     (ranker
  