@hackage sphinx0.6.1

Haskell bindings to the Sphinx full-text searching daemon.

<p>A haskell implementation of a <a href="http://sphinxsearch.com">sphinx full text search</a> client. Sphinx is a very fast and featureful full-text search daemon. Version 0.4 is Compatible with sphinx version 1.1-beta Version 0.5+ is Compatible with sphinx version 2.0, but you can instead pass the version-one-one build flag. <a href="http://hackage.haskell.org/package/sphinx">On hackage</a>.</p> <h1 id="usage">Usage</h1> <h2 id="constructing-queries">Constructing Queries</h2> <p>The data type <code>Query</code> is used to represent queries to the server. It specifies a search string and the indexes to run the query on, as well as a comment, which may be the empty string. In order to run a query on all indexes, use <code>&quot;*&quot;</code> in the index field.</p> <p>The convenience function <code>query</code> executes a single query and constructs the <code>Query</code> by itself, so you don't have to.</p> <p>To execute more than one <code>Query</code>, use <code>runQueries</code>. Details are below in the section <a href="#batch-queries"><em>Batch Queries</em></a>. To construct simple queries, you can also use <code>simpleQuery :: Text -&gt; Query</code> which constructs a <code>Query</code> over all indexes. Don't forget that you can use record updates on a <code>Query</code>.</p> <p>In extended mode you may want to escape special query characters with <code>escapeString</code>.</p> <p>All interaction with the server, including sending queries and receiving results, is based on the <code>Data.Text</code> string type. You might therefore want to enable the <code>OverloadedStrings</code> pragma.</p> <h2 id="excerpts-and-xml-indexes">Excerpts and XML Indexes</h2> <p><code>buildExcerpts</code> creates highlighted excerpts.</p> <p>You will probably need to import the types as well:</p> <pre><code>import qualified Text.Search.Sphinx as Sphinx import qualified Text.Search.Sphinx.Types as SphinxT </code></pre> <p>There is also an <code>Indexable</code> module for generating an xml file of data to be indexed.</p> <h2 id="batch-queries">Batch Queries</h2> <p>You can send more than one query per request to the server (which may enable server-side query optimization in certain cases. Refer to the <a href="http://sphinxsearch.com/docs/2.0.4/api-func-addquery.html">Sphinx manual</a> for details.) The function <code>runQueries</code> pipelines multiple queries together. If you are trying to combine the results, there are some helpers such as <code>maybeQueries</code> and <code>resultsToMatches</code>.</p> <pre><code class="language-{.haskell}"> mr &lt;- Sphinx.maybeQueries sphinxLogger sphinxConfig [ SphinxT.Query query1 &quot;db1&quot; &quot;&quot; , SphinxT.Query query1 &quot;db2&quot; &quot;&quot; , SphinxT.Query query2 &quot;db1&quot; &quot;&quot; , SphinxT.Query query2 &quot;db2&quot; &quot;&quot; ] case mr of Nothing -&gt; return Nothing Just rs -&gt; do let combined = Sphinx.resultsToMatches 20 rs if null combined then return Nothing else return $ Just combined </code></pre> <p><strong>A note</strong> for those transitioning from <code>0.5.*</code> to <code>0.6</code>: the function <code>addQueries</code> has been removed. You can now directly send a list of <code>Query</code> to the server by using <code>runQueries</code>, which will handle the serialization for you behind the scenes.</p> <h2 id="encoding">Encoding</h2> <p>The sphinx server itself does not know about encodings except for the difference between single-byte encodings and multi-byte encodings. It assumes that all incoming queries are already properly encoded and matches the raw bytes it receives; the same holds for the results returned by the server. Hence the responsibilty for using the proper encoding (and decoding) routines lies with the caller.</p> <p>Version 0.6.0 of <code>haskell-sphinx-client</code> introduces the <code>encoding</code> field in both the <code>Configuration</code> data type and the <code>ExcerptConfiguration</code> data type. The library handles proper encoding and decoding in the background; just make sure you set the right encoding setting in the configuration!</p> <h1 id="details">Details</h1> <h2 id="implemenation">Implemenation</h2> <p>Implementation of API as detailed in <a href="http://sphinxsearch.com/docs/manual-1.10.html">the documentation</a>. Most search and buildExcerpts features are implemented.</p> <h2 id="history">History</h2> <p>Originally written by Tupil and maintained by Chris Eidhof for an earlier version of sphinx. Greg Weber improved the library and updated it for the latest version of sphinx. Aleksandar Dimitrov updated the library to use Text. The Haskell team of <a href="https://chordify.net">Chordify</a> is now maintaining the library.</p> <h2 id="usage-of-this-haskell-client">Usage of this haskell client</h2> <p>Tupil originally wrote this for use on a commercial project. This sphinx package is now finding some use in the Yesod community. <a href="https://github.com/yesodweb/yesod/wiki/Sphinx-Search">Here is a well described example usage</a>, but do keep in mind there is no requirement to tie the <em>generation</em> of sphinx documents to your web application, just your database. Used in Yesod applications yesdoweb.com and eatnutrients.com.</p>