Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add simpleQuery; it produces lightweight queries.

  • Loading branch information...
commit 5b4f2d7b212086334d3d479a7aadaf31edc17a6f 1 parent aad36d2
Aleksandar Dimitrov adimit authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 Text/Search/Sphinx.hs
9 Text/Search/Sphinx.hs
View
@@ -12,6 +12,7 @@ module Text.Search.Sphinx ( module Text.Search.Sphinx
import qualified Text.Search.Sphinx.Types as T (
Match,
+ Query(..),
VerCommand(VcSearch, VcExcerpt),
SearchdCommand(ScSearch, ScExcerpt),
Filter, Filter(..),
@@ -38,6 +39,9 @@ import Data.Bits ((.|.))
import Prelude hiding (filter, tail)
import Data.List (nub)
+import Data.Text (Text)
+import qualified Data.Text as X
+
{- the funnest way to debug this is to run the same query with an existing working client and look at the difference
- sudo tcpflow -i lo dst port 9306
import Debug.Trace; debug a = trace (show a) a
@@ -78,6 +82,11 @@ query config indexes search = do
T.QueryWarning w result -> T.Warning (BS.append warning w) result
T.QueryError code e -> T.Error code e
+-- | Prepare a commentless query over all indexes
+simpleQuery :: Text -- ^ The query string
+ -> T.Query -- ^ A query value that can be sent to @runQueries@
+simpleQuery q = T.Query q "*" X.empty
+
connect :: String -> Int -> IO Handle
connect host port = do
connection <- connectTo host (PortNumber $ fromIntegral $ port)
Please sign in to comment.
Something went wrong with that request. Please try again.