{-# LANGUAGE CPP #-}
module Network.Riak.Search
( IndexInfo
, SearchResult(..)
, Score
, indexInfo
, getIndex
, putIndex
, deleteIndex
, searchRaw
) where
#if __GLASGOW_HASKELL__ <= 708
import Control.Applicative
#endif
import Data.Sequence (Seq)
import Network.Riak.Connection.Internal
import Network.Riak.Protocol.Content (Content)
import Network.Riak.Protocol.YzIndex (YzIndex(YzIndex))
import qualified Network.Riak.Request as Req
import qualified Network.Riak.Response as Resp
import Network.Riak.Types.Internal
indexInfo :: Index -> Maybe Schema -> Maybe N -> IndexInfo
indexInfo = YzIndex
getIndex :: Connection -> Maybe Index -> IO [IndexInfo]
getIndex conn ix = Resp.getIndex <$> exchange conn (Req.getIndex ix)
putIndex :: Connection -> IndexInfo -> Maybe Timeout -> IO (Seq Content, VClock)
putIndex conn info timeout = Resp.put <$> exchange conn (Req.putIndex info timeout)
deleteIndex :: Connection -> Index -> IO ()
deleteIndex conn ix = exchange_ conn (Req.deleteIndex ix)
searchRaw :: Connection -> SearchQuery -> Index -> IO SearchResult
searchRaw conn q ix = Resp.search <$> exchange conn (Req.search q ix)