Case Study: Sphinx-based Search

Sphinx is a search server, and powers the search feature on many sites. While the actual code necessary to integrate Yesod with Sphinx is relatively short, it touches on a number of complicated topics, and is therefore a great case study in how to play with some of the under-the-surface details of Yesod.

There are essentially three different pieces at play here:

  • Storing the content we wish to search. This is fairly straight-forward Persistent code, and we won’t dwell on it much in this chapter.

  • Accessing Sphinx search results from inside Yesod. Thanks to the sphinx package, this is actually very easy.

  • Providing the document content to Sphinx. This is where the interesting stuff happens, and will show how to deal with streaming content from a database directly to XML, which gets sent directly over the wire to the client.

The full code for this example can be found on FP Haskell Center.

Sphinx Setup

Unlike many of our other examples, to start with here we’ll need to actually configure and run our external Sphinx server. I’m not going to go into all the details of Sphinx, partly because it’s not relevant to our point here, and mostly because I’m not an expert on Sphinx.

Sphinx provides three main command line utilities: searchd is the actual search daemon that receives requests from the client (in this case, our web app) and returns the search results. indexer parses the set of documents and creates the search index. search is a debugging utility that will run simple queries against Sphinx.

There are two important settings: the source and the index. The source tells Sphinx where to read document information from. It has direct support for MySQL and PostgreSQL, as well as a more general XML format known as xmlpipe2. We’re going to use the last one. This not only will give us more flexibility with choosing Persistent backends, but will also demonstrate some more powerful Yesod concepts.

The second setting is the index. Sphinx can handle multiple indices simultaneously, which allows it to provide search for multiple services at once. Each index will have a source it pulls from.

In our case, we’re going to provide a URL from our application (/search/xmlpipe) that provides the XML file required by Sphinx, and then pipe that through to the indexer. So we’ll add the following to our Sphinx config file:

  1. source searcher_src
  2. {
  3. type = xmlpipe2
  4. xmlpipe_command = curl http://localhost:3000/search/xmlpipe
  5. }
  6. index searcher
  7. {
  8. source = searcher_src
  9. path = /var/data/searcher
  10. docinfo = extern
  11. charset_type = utf-8
  12. }
  13. searchd
  14. {
  15. listen = 9312
  16. pid_file = /var/run/sphinxsearch/searchd.pid
  17. }

In order to build your search index, you would run indexer searcher. Obviously this won’t work until you have your web app running. For a production site, it would make sense to run this command via a crontab script so the index is regularly updated.

Basic Yesod Setup

Let’s get our basic Yesod setup going. We’re going to have a single table in the database for holding documents, which consist of a title and content. We’ll store this in a SQLite database, and provide routes for searching, adding documents, viewing documents and providing the xmlpipe file to Sphinx.

  1. share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
  2. Doc
  3. title Text
  4. content Textarea
  5. |]
  6. data Searcher = Searcher
  7. { connPool :: ConnectionPool
  8. }
  9. mkYesod "Searcher" [parseRoutes|
  10. / HomeR GET
  11. /doc/#DocId DocR GET
  12. /add-doc AddDocR POST
  13. /search SearchR GET
  14. /search/xmlpipe XmlpipeR GET
  15. |]
  16. instance Yesod Searcher
  17. instance YesodPersist Searcher where
  18. type YesodPersistBackend Searcher = SqlPersistT
  19. runDB action = do
  20. Searcher pool <- getYesod
  21. runSqlPool action pool
  22. instance YesodPersistRunner Searcher where -- see below
  23. getDBRunner = defaultGetDBRunner connPool
  24. instance RenderMessage Searcher FormMessage where
  25. renderMessage _ _ = defaultFormMessage

Hopefully all of this looks pretty familiar by now. The one new thing we’ve defined here is an instance of YesodPersistRunner. This is a typeclass necessary for creating streaming database responses. The default implementation (defaultGetDBRunner) is almost always appropriate.

Next we’ll define some forms: one for creating documents, and one for searching:

  1. addDocForm :: Html -> MForm Handler (FormResult Doc, Widget)
  2. addDocForm = renderTable $ Doc
  3. <$> areq textField "Title" Nothing
  4. <*> areq textareaField "Contents" Nothing
  5. searchForm :: Html -> MForm Handler (FormResult Text, Widget)
  6. searchForm = renderDivs $ areq (searchField True) "Query" Nothing

The True parameter to searchField makes the field auto-focus on page load. Finally, we have some standard handlers for the homepage (shows the add document form and the search form), the document display, and adding a document.

  1. getHomeR :: Handler Html
  2. getHomeR = do
  3. docCount <- runDB $ count ([] :: [Filter Doc])
  4. ((_, docWidget), _) <- runFormPost addDocForm
  5. ((_, searchWidget), _) <- runFormGet searchForm
  6. let docs = if docCount == 1
  7. then "There is currently 1 document."
  8. else "There are currently " ++ show docCount ++ " documents."
  9. defaultLayout
  10. [whamlet|
  11. <p>Welcome to the search application. #{docs}
  12. <form method=post action=@{AddDocR}>
  13. <table>
  14. ^{docWidget}
  15. <tr>
  16. <td colspan=3>
  17. <input type=submit value="Add document">
  18. <form method=get action=@{SearchR}>
  19. ^{searchWidget}
  20. <input type=submit value=Search>
  21. |]
  22. postAddDocR :: Handler Html
  23. postAddDocR = do
  24. ((res, docWidget), _) <- runFormPost addDocForm
  25. case res of
  26. FormSuccess doc -> do
  27. docid <- runDB $ insert doc
  28. setMessage "Document added"
  29. redirect $ DocR docid
  30. _ -> defaultLayout
  31. [whamlet|
  32. <form method=post action=@{AddDocR}>
  33. <table>
  34. ^{docWidget}
  35. <tr>
  36. <td colspan=3>
  37. <input type=submit value="Add document">
  38. |]
  39. getDocR :: DocId -> Handler Html
  40. getDocR docid = do
  41. doc <- runDB $ get404 docid
  42. defaultLayout
  43. [whamlet|
  44. <h1>#{docTitle doc}
  45. <div .content>#{docContent doc}
  46. |]

Searching

Now that we’ve got the boring stuff out of the way, let’s jump into the actual searching. We’re going to need three pieces of information for displaying a result: the document ID it comes from, the title of that document, and the excerpts. Excerpts are the highlighted portions of the document which contain the search term.

Search Result

Case Study: Sphinx-based Search - 图1

So let’s start off by defining a Result datatype:

  1. data Result = Result
  2. { resultId :: DocId
  3. , resultTitle :: Text
  4. , resultExcerpt :: Html
  5. }

Next we’ll look at the search handler:

  1. getSearchR :: Handler Html
  2. getSearchR = do
  3. ((formRes, searchWidget), _) <- runFormGet searchForm
  4. searchResults <-
  5. case formRes of
  6. FormSuccess qstring -> getResults qstring
  7. _ -> return []
  8. defaultLayout $ do
  9. toWidget
  10. [lucius|
  11. .excerpt {
  12. color: green; font-style: italic
  13. }
  14. .match {
  15. background-color: yellow;
  16. }
  17. |]
  18. [whamlet|
  19. <form method=get action=@{SearchR}>
  20. ^{searchWidget}
  21. <input type=submit value=Search>
  22. $if not $ null searchResults
  23. <h1>Results
  24. $forall result <- searchResults
  25. <div .result>
  26. <a href=@{DocR $ resultId result}>#{resultTitle result}
  27. <div .excerpt>#{resultExcerpt result}
  28. |]

Nothing magical here, we’re just relying on the searchForm defined above, and the getResults function which hasn’t been defined yet. This function just takes a search string, and returns a list of results. This is where we first interact with the Sphinx API. We’ll be using two functions: query will return a list of matches, and buildExcerpts will return the highlighted excerpts. Let’s first look at getResults:

  1. getResults :: Text -> Handler [Result]
  2. getResults qstring = do
  3. sphinxRes' <- liftIO $ S.query config "searcher" $ T.unpack qstring
  4. case sphinxRes' of
  5. ST.Ok sphinxRes -> do
  6. let docids = map (Key . PersistInt64 . ST.documentId) $ ST.matches sphinxRes
  7. fmap catMaybes $ runDB $ forM docids $ \docid -> do
  8. mdoc <- get docid
  9. case mdoc of
  10. Nothing -> return Nothing
  11. Just doc -> liftIO $ Just <$> getResult docid doc qstring
  12. _ -> error $ show sphinxRes'
  13. where
  14. config = S.defaultConfig
  15. { S.port = 9312
  16. , S.mode = ST.Any
  17. }

query takes three parameters: the configuration options, the index to search against (searcher in this case) and the search string. It returns a list of document IDs that contain the search string. The tricky bit here is that those documents are returned as Int64 values, whereas we need DocIds. We’re taking advantage of the fact that the SQL Persistent backends use a PersistInt64 constructor for their IDs, and simply wrap up the values appropriately.

If you’re dealing with a backend that has non-numeric IDs, like MongoDB, you’ll need to work out something a bit more clever than this.

We then loop over the resulting IDs to get a [Maybe Result] value, and use catMaybes to turn it into a [Result]. In the where clause, we define our local settings, which override the default port and set up the search to work when any term matches the document.

Let’s finally look at the getResult function:

  1. getResult :: DocId -> Doc -> Text -> IO Result
  2. getResult docid doc qstring = do
  3. excerpt' <- S.buildExcerpts
  4. excerptConfig
  5. [T.unpack $ escape $ docContent doc]
  6. "searcher"
  7. (T.unpack qstring)
  8. let excerpt =
  9. case excerpt' of
  10. ST.Ok bss -> preEscapedToHtml $ decodeUtf8 $ mconcat bss
  11. _ -> ""
  12. return Result
  13. { resultId = docid
  14. , resultTitle = docTitle doc
  15. , resultExcerpt = excerpt
  16. }
  17. where
  18. excerptConfig = E.altConfig { E.port = 9312 }
  19. escape :: Textarea -> Text
  20. escape =
  21. T.concatMap escapeChar . unTextarea
  22. where
  23. escapeChar '<' = "&lt;"
  24. escapeChar '>' = "&gt;"
  25. escapeChar '&' = "&amp;"
  26. escapeChar c = T.singleton c

buildExcerpts takes four parameters: the configuration options, the textual contents of the document, the search index and the search term. The interesting bit is that we entity escape the text content. Sphinx won’t automatically escape these for us, so we must do it explicitly.

Similarly, the result from Sphinx is a list of Texts. But of course, we’d rather have Html. So we concat that list into a single Text and use preEscapedToHtml to make sure that the tags inserted for matches are not escaped. A sample of this HTML is:

  1. &#8230; Departments. The President shall have <span class='match'>Power</span> to fill up all Vacancies
  2. &#8230; people. Amendment 11 The Judicial <span class='match'>power</span> of the United States shall
  3. &#8230; jurisdiction. 2. Congress shall have <span class='match'>power</span> to enforce this article by
  4. &#8230; 5. The Congress shall have <span class='match'>power</span> to enforce, by appropriate legislation
  5. &#8230;

Streaming xmlpipe output

We’ve saved the best for last. For the majority of Yesod handlers, the recommended approach is to load up the database results into memory and then produce the output document based on that. It’s simpler to work with, but more importantly it’s more resilient to exceptions. If there’s a problem loading the data from the database, the user will get a proper 500 response code.

What do I mean by “proper 500 response code?” If you start streaming a response to a client, and encounter an exception halfway through, there’s no way to change the status code; the user will see a 200 response that simply stops in the middle. Not only can this partial content be confusing, but it’s an invalid usage of the HTTP spec.

However, generating the xmlpipe output is a perfect example of the alternative. There are potentially a huge number of documents, and documents could easily be several hundred kilobytes. If we take a non-streaming approach, this can lead to huge memory usage and slow response times.

So how exactly do we create a streaming response? Yesod provides a helper function for this case: responseSourceDB. This function takes two arguments: a content type, and a conduit Source providing a stream of blaze-builder Builders. Yesod that handles all of the issues of grabbing a database connection from the connection pool, starting a transaction, and streaming the response to the user.

Now we know we want to create a stream of Builders from some XML content. Fortunately, the xml-conduit package provides this interface directly. xml-conduit provides some high-level interfaces for dealing with documents as a whole, but in our case, we’re going to need to use the low-level Event interface to ensure minimal memory impact. So the function we’re interested in is:

  1. renderBuilder :: Monad m => RenderSettings -> Conduit Event m Builder

In plain English, that means renderBuilder takes some settings (we’ll just use the defaults), and will then convert a stream of Events to a stream of Builders. This is looking pretty good, all we need now is a stream of Events.

Speaking of which, what should our XML document actually look like? It’s pretty simple, we have a sphinx:docset root element, a sphinx:schema element containing a single sphinx:field (which defines the content field), and then a sphinx:document for each document in our database. That last element will have an id attribute and a child content element. Below is an example of such a document:

  1. <sphinx:docset xmlns:sphinx="http://sphinxsearch.com/">
  2. <sphinx:schema>
  3. <sphinx:field name="content"/>
  4. </sphinx:schema>
  5. <sphinx:document id="1">
  6. <content>bar</content>
  7. </sphinx:document>
  8. <sphinx:document id="2">
  9. <content>foo bar baz</content>
  10. </sphinx:document>
  11. </sphinx:docset>

Every document is going to start off with the same events (start the docset, start the schema, etc) and end with the same event (end the docset). We’ll start off by defining those:

  1. toName :: Text -> X.Name
  2. toName x = X.Name x (Just "http://sphinxsearch.com/") (Just "sphinx")
  3. docset, schema, field, document, content :: X.Name
  4. docset = toName "docset"
  5. schema = toName "schema"
  6. field = toName "field"
  7. document = toName "document"
  8. content = "content" -- no prefix
  9. startEvents, endEvents :: [X.Event]
  10. startEvents =
  11. [ X.EventBeginDocument
  12. , X.EventBeginElement docset []
  13. , X.EventBeginElement schema []
  14. , X.EventBeginElement field [("name", [X.ContentText "content"])]
  15. , X.EventEndElement field
  16. , X.EventEndElement schema
  17. ]
  18. endEvents =
  19. [ X.EventEndElement docset
  20. ]

Now that we have the shell of our document, we need to get the Events for each individual document. This is actually a fairly simple function:

  1. entityToEvents :: (Entity Doc) -> [X.Event]
  2. entityToEvents (Entity docid doc) =
  3. [ X.EventBeginElement document [("id", [X.ContentText $ toPathPiece docid])]
  4. , X.EventBeginElement content []
  5. , X.EventContent $ X.ContentText $ unTextarea $ docContent doc
  6. , X.EventEndElement content
  7. , X.EventEndElement document
  8. ]

We start the document element with an id attribute, start the content, insert the content, and then close both elements. We use toPathPiece to convert a DocId into a Text value. Next, we need to be able to convert a stream of these entities into a stream of events. For this, we can use the built-in concatMap function from Data.Conduit.List: CL.concatMap entityToEvents.

But what we really want is to stream those events directly from the database. For most of this book, we’ve used the selectList function, but Persistent also provides the (more powerful) selectSource function. So we end up with the function:

  1. docSource :: Source (YesodDB Searcher) X.Event
  2. docSource = selectSource [] [] $= CL.concatMap entityToEvents

The $= operator joins together a source and a conduit into a new source. Now that we have our Event source, all we need to do is surround it with the document start and end events. With Source‘s Monad instance, this is a piece of cake:

  1. fullDocSource :: Source (YesodDB Searcher) X.Event
  2. fullDocSource = do
  3. mapM_ yield startEvents
  4. docSource
  5. mapM_ yield endEvents

Now we need to tie it together in getXmlpipeR. To do so, we’ll use the respondSourceDB function mentioned earlier. The last trick we need to do is convert our stream of Events into a stream of Chunk Builders. Converting to a stream of Builders is achieved with renderBuilder, and finally we’ll just wrap each Builder in its own Chunk:

  1. getXmlpipeR :: Handler TypedContent
  2. getXmlpipeR =
  3. respondSourceDB "text/xml"
  4. $ fullDocSource
  5. $= renderBuilder def
  6. $= CL.map Chunk

Full code

  1. {-# LANGUAGE FlexibleContexts #-}
  2. {-# LANGUAGE GADTs #-}
  3. {-# LANGUAGE MultiParamTypeClasses #-}
  4. {-# LANGUAGE OverloadedStrings #-}
  5. {-# LANGUAGE QuasiQuotes #-}
  6. {-# LANGUAGE TemplateHaskell #-}
  7. {-# LANGUAGE TypeFamilies #-}
  8. import Control.Applicative ((<$>), (<*>))
  9. import Control.Monad (forM)
  10. import Control.Monad.Logger (runStdoutLoggingT)
  11. import Data.Conduit
  12. import qualified Data.Conduit.List as CL
  13. import Data.Maybe (catMaybes)
  14. import Data.Monoid (mconcat)
  15. import Data.Text (Text)
  16. import qualified Data.Text as T
  17. import Data.Text.Lazy.Encoding (decodeUtf8)
  18. import qualified Data.XML.Types as X
  19. import Database.Persist.Sqlite
  20. import Text.Blaze.Html (preEscapedToHtml)
  21. import qualified Text.Search.Sphinx as S
  22. import qualified Text.Search.Sphinx.ExcerptConfiguration as E
  23. import qualified Text.Search.Sphinx.Types as ST
  24. import Text.XML.Stream.Render (def, renderBuilder)
  25. import Yesod
  26. share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
  27. Doc
  28. title Text
  29. content Textarea
  30. |]
  31. data Searcher = Searcher
  32. { connPool :: ConnectionPool
  33. }
  34. mkYesod "Searcher" [parseRoutes|
  35. / HomeR GET
  36. /doc/#DocId DocR GET
  37. /add-doc AddDocR POST
  38. /search SearchR GET
  39. /search/xmlpipe XmlpipeR GET
  40. |]
  41. instance Yesod Searcher
  42. instance YesodPersist Searcher where
  43. type YesodPersistBackend Searcher = SqlPersistT
  44. runDB action = do
  45. Searcher pool <- getYesod
  46. runSqlPool action pool
  47. instance YesodPersistRunner Searcher where
  48. getDBRunner = defaultGetDBRunner connPool
  49. instance RenderMessage Searcher FormMessage where
  50. renderMessage _ _ = defaultFormMessage
  51. addDocForm :: Html -> MForm Handler (FormResult Doc, Widget)
  52. addDocForm = renderTable $ Doc
  53. <$> areq textField "Title" Nothing
  54. <*> areq textareaField "Contents" Nothing
  55. searchForm :: Html -> MForm Handler (FormResult Text, Widget)
  56. searchForm = renderDivs $ areq (searchField True) "Query" Nothing
  57. getHomeR :: Handler Html
  58. getHomeR = do
  59. docCount <- runDB $ count ([] :: [Filter Doc])
  60. ((_, docWidget), _) <- runFormPost addDocForm
  61. ((_, searchWidget), _) <- runFormGet searchForm
  62. let docs = if docCount == 1
  63. then "There is currently 1 document."
  64. else "There are currently " ++ show docCount ++ " documents."
  65. defaultLayout
  66. [whamlet|
  67. <p>Welcome to the search application. #{docs}
  68. <form method=post action=@{AddDocR}>
  69. <table>
  70. ^{docWidget}
  71. <tr>
  72. <td colspan=3>
  73. <input type=submit value="Add document">
  74. <form method=get action=@{SearchR}>
  75. ^{searchWidget}
  76. <input type=submit value=Search>
  77. |]
  78. postAddDocR :: Handler Html
  79. postAddDocR = do
  80. ((res, docWidget), _) <- runFormPost addDocForm
  81. case res of
  82. FormSuccess doc -> do
  83. docid <- runDB $ insert doc
  84. setMessage "Document added"
  85. redirect $ DocR docid
  86. _ -> defaultLayout
  87. [whamlet|
  88. <form method=post action=@{AddDocR}>
  89. <table>
  90. ^{docWidget}
  91. <tr>
  92. <td colspan=3>
  93. <input type=submit value="Add document">
  94. |]
  95. getDocR :: DocId -> Handler Html
  96. getDocR docid = do
  97. doc <- runDB $ get404 docid
  98. defaultLayout
  99. [whamlet|
  100. <h1>#{docTitle doc}
  101. <div .content>#{docContent doc}
  102. |]
  103. data Result = Result
  104. { resultId :: DocId
  105. , resultTitle :: Text
  106. , resultExcerpt :: Html
  107. }
  108. getResult :: DocId -> Doc -> Text -> IO Result
  109. getResult docid doc qstring = do
  110. excerpt' <- S.buildExcerpts
  111. excerptConfig
  112. [T.unpack $ escape $ docContent doc]
  113. "searcher"
  114. (T.unpack qstring)
  115. let excerpt =
  116. case excerpt' of
  117. ST.Ok bss -> preEscapedToHtml $ decodeUtf8 $ mconcat bss
  118. _ -> ""
  119. return Result
  120. { resultId = docid
  121. , resultTitle = docTitle doc
  122. , resultExcerpt = excerpt
  123. }
  124. where
  125. excerptConfig = E.altConfig { E.port = 9312 }
  126. escape :: Textarea -> Text
  127. escape =
  128. T.concatMap escapeChar . unTextarea
  129. where
  130. escapeChar '<' = "&lt;"
  131. escapeChar '>' = "&gt;"
  132. escapeChar '&' = "&amp;"
  133. escapeChar c = T.singleton c
  134. getResults :: Text -> Handler [Result]
  135. getResults qstring = do
  136. sphinxRes' <- liftIO $ S.query config "searcher" $ T.unpack qstring
  137. case sphinxRes' of
  138. ST.Ok sphinxRes -> do
  139. let docids = map (Key . PersistInt64 . ST.documentId) $ ST.matches sphinxRes
  140. fmap catMaybes $ runDB $ forM docids $ \docid -> do
  141. mdoc <- get docid
  142. case mdoc of
  143. Nothing -> return Nothing
  144. Just doc -> liftIO $ Just <$> getResult docid doc qstring
  145. _ -> error $ show sphinxRes'
  146. where
  147. config = S.defaultConfig
  148. { S.port = 9312
  149. , S.mode = ST.Any
  150. }
  151. getSearchR :: Handler Html
  152. getSearchR = do
  153. ((formRes, searchWidget), _) <- runFormGet searchForm
  154. searchResults <-
  155. case formRes of
  156. FormSuccess qstring -> getResults qstring
  157. _ -> return []
  158. defaultLayout $ do
  159. toWidget
  160. [lucius|
  161. .excerpt {
  162. color: green; font-style: italic
  163. }
  164. .match {
  165. background-color: yellow;
  166. }
  167. |]
  168. [whamlet|
  169. <form method=get action=@{SearchR}>
  170. ^{searchWidget}
  171. <input type=submit value=Search>
  172. $if not $ null searchResults
  173. <h1>Results
  174. $forall result <- searchResults
  175. <div .result>
  176. <a href=@{DocR $ resultId result}>#{resultTitle result}
  177. <div .excerpt>#{resultExcerpt result}
  178. |]
  179. getXmlpipeR :: Handler TypedContent
  180. getXmlpipeR =
  181. respondSourceDB "text/xml"
  182. $ fullDocSource
  183. $= renderBuilder def
  184. $= CL.map Chunk
  185. entityToEvents :: (Entity Doc) -> [X.Event]
  186. entityToEvents (Entity docid doc) =
  187. [ X.EventBeginElement document [("id", [X.ContentText $ toPathPiece docid])]
  188. , X.EventBeginElement content []
  189. , X.EventContent $ X.ContentText $ unTextarea $ docContent doc
  190. , X.EventEndElement content
  191. , X.EventEndElement document
  192. ]
  193. fullDocSource :: Source (YesodDB Searcher) X.Event
  194. fullDocSource = do
  195. mapM_ yield startEvents
  196. docSource
  197. mapM_ yield endEvents
  198. docSource :: Source (YesodDB Searcher) X.Event
  199. docSource = selectSource [] [] $= CL.concatMap entityToEvents
  200. toName :: Text -> X.Name
  201. toName x = X.Name x (Just "http://sphinxsearch.com/") (Just "sphinx")
  202. docset, schema, field, document, content :: X.Name
  203. docset = toName "docset"
  204. schema = toName "schema"
  205. field = toName "field"
  206. document = toName "document"
  207. content = "content" -- no prefix
  208. startEvents, endEvents :: [X.Event]
  209. startEvents =
  210. [ X.EventBeginDocument
  211. , X.EventBeginElement docset []
  212. , X.EventBeginElement schema []
  213. , X.EventBeginElement field [("name", [X.ContentText "content"])]
  214. , X.EventEndElement field
  215. , X.EventEndElement schema
  216. ]
  217. endEvents =
  218. [ X.EventEndElement docset
  219. ]
  220. main :: IO ()
  221. main = withSqlitePool "searcher.db3" 10 $ \pool -> do
  222. runStdoutLoggingT $ runSqlPool (runMigration migrateAll) pool
  223. warp 3000 $ Searcher pool