Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > d0983343df85ecf7d844c2cfc3a0597a > files > 496

python-whoosh-2.5.1-1.fc18.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Whoosh recipes &mdash; Whoosh 2.5.1 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '2.5.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Whoosh 2.5.1 documentation" href="index.html" />
    <link rel="next" title="Whoosh API" href="api/api.html" />
    <link rel="prev" title="Indexing and searching document hierarchies" href="nested.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="api/api.html" title="Whoosh API"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="nested.html" title="Indexing and searching document hierarchies"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Whoosh 2.5.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="whoosh-recipes">
<h1>Whoosh recipes<a class="headerlink" href="#whoosh-recipes" title="Permalink to this headline">¶</a></h1>
<div class="section" id="general">
<h2>General<a class="headerlink" href="#general" title="Permalink to this headline">¶</a></h2>
<div class="section" id="get-the-stored-fields-for-a-document-from-the-document-number">
<h3>Get the stored fields for a document from the document number<a class="headerlink" href="#get-the-stored-fields-for-a-document-from-the-document-number" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stored_fields</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">stored_fields</span><span class="p">(</span><span class="n">docnum</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="analysis">
<h2>Analysis<a class="headerlink" href="#analysis" title="Permalink to this headline">¶</a></h2>
<div class="section" id="eliminate-words-shorter-longer-than-n">
<h3>Eliminate words shorter/longer than N<a class="headerlink" href="#eliminate-words-shorter-longer-than-n" title="Permalink to this headline">¶</a></h3>
<p>Use a <a class="reference internal" href="api/analysis.html#whoosh.analysis.StopFilter" title="whoosh.analysis.StopFilter"><tt class="xref py py-class docutils literal"><span class="pre">StopFilter</span></tt></a> and the <tt class="docutils literal"><span class="pre">minsize</span></tt> and <tt class="docutils literal"><span class="pre">maxsize</span></tt>
keyword arguments. If you just want to filter based on size and not common
words, set the <tt class="docutils literal"><span class="pre">stoplist</span></tt> to <tt class="docutils literal"><span class="pre">None</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">sf</span> <span class="o">=</span> <span class="n">analysis</span><span class="o">.</span><span class="n">StopFilter</span><span class="p">(</span><span class="n">stoplist</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">minsize</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">maxsize</span><span class="o">=</span><span class="mi">40</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="allow-optional-case-sensitive-searches">
<h3>Allow optional case-sensitive searches<a class="headerlink" href="#allow-optional-case-sensitive-searches" title="Permalink to this headline">¶</a></h3>
<p>A quick and easy way to do this is to index both the original and lowercased
versions of each word. If the user searches for an all-lowercase word, it acts
as a case-insensitive search, but if they search for a word with any uppercase
characters, it acts as a case-sensitive search:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">CaseSensitivizer</span><span class="p">(</span><span class="n">analysis</span><span class="o">.</span><span class="n">Filter</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tokens</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">tokens</span><span class="p">:</span>
            <span class="k">yield</span> <span class="n">t</span>
            <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">mode</span> <span class="o">==</span> <span class="s">&quot;index&quot;</span><span class="p">:</span>
               <span class="n">low</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
               <span class="k">if</span> <span class="n">low</span> <span class="o">!=</span> <span class="n">t</span><span class="o">.</span><span class="n">text</span><span class="p">:</span>
                   <span class="n">t</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">low</span>
                   <span class="k">yield</span> <span class="n">t</span>

<span class="n">ana</span> <span class="o">=</span> <span class="n">analysis</span><span class="o">.</span><span class="n">RegexTokenizer</span><span class="p">()</span> <span class="o">|</span> <span class="n">CaseSensitivizer</span><span class="p">()</span>
<span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">text</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">ana</span><span class="p">(</span><span class="s">&quot;The new SuperTurbo 5000&quot;</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s">&quot;index&quot;</span><span class="p">)]</span>
<span class="c"># [&quot;The&quot;, &quot;the&quot;, &quot;new&quot;, &quot;SuperTurbo&quot;, &quot;superturbo&quot;, &quot;5000&quot;]</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="searching">
<h2>Searching<a class="headerlink" href="#searching" title="Permalink to this headline">¶</a></h2>
<div class="section" id="find-every-document">
<h3>Find every document<a class="headerlink" href="#find-every-document" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="n">myquery</span> <span class="o">=</span> <span class="n">query</span><span class="o">.</span><span class="n">Every</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="itunes-style-search-as-you-type">
<h3>iTunes-style search-as-you-type<a class="headerlink" href="#itunes-style-search-as-you-type" title="Permalink to this headline">¶</a></h3>
<p>Use the <a class="reference internal" href="api/analysis.html#whoosh.analysis.NgramWordAnalyzer" title="whoosh.analysis.NgramWordAnalyzer"><tt class="xref py py-class docutils literal"><span class="pre">whoosh.analysis.NgramWordAnalyzer</span></tt></a> as the analyzer for the
field you want to search as the user types. You can save space in the index by
turning off positions in the field using <tt class="docutils literal"><span class="pre">phrase=False</span></tt>, since phrase
searching on N-gram fields usually doesn&#8217;t make much sense:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># For example, to search the &quot;title&quot; field as the user types</span>
<span class="n">analyzer</span> <span class="o">=</span> <span class="n">analysis</span><span class="o">.</span><span class="n">NgramWordAnalyzer</span><span class="p">()</span>
<span class="n">title_field</span> <span class="o">=</span> <span class="n">fields</span><span class="o">.</span><span class="n">TEXT</span><span class="p">(</span><span class="n">analyzer</span><span class="o">=</span><span class="n">analyzer</span><span class="p">,</span> <span class="n">phrase</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="n">schema</span> <span class="o">=</span> <span class="n">fields</span><span class="o">.</span><span class="n">Schema</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="n">title_field</span><span class="p">)</span>
</pre></div>
</div>
<p>See the documentation for the <a class="reference internal" href="api/analysis.html#whoosh.analysis.NgramWordAnalyzer" title="whoosh.analysis.NgramWordAnalyzer"><tt class="xref py py-class docutils literal"><span class="pre">NgramWordAnalyzer</span></tt></a> class
for information on the available options.</p>
</div>
</div>
<div class="section" id="shortcuts">
<h2>Shortcuts<a class="headerlink" href="#shortcuts" title="Permalink to this headline">¶</a></h2>
<div class="section" id="look-up-documents-by-a-field-value">
<h3>Look up documents by a field value<a class="headerlink" href="#look-up-documents-by-a-field-value" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Single document (unique field value)</span>
<span class="n">stored_fields</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">document</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="s">&quot;bacon&quot;</span><span class="p">)</span>

<span class="c"># Multiple documents</span>
<span class="k">for</span> <span class="n">stored_fields</span> <span class="ow">in</span> <span class="n">searcher</span><span class="o">.</span><span class="n">documents</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s">&quot;cake&quot;</span><span class="p">):</span>
    <span class="o">...</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="sorting-and-scoring">
<h2>Sorting and scoring<a class="headerlink" href="#sorting-and-scoring" title="Permalink to this headline">¶</a></h2>
<p>See <a class="reference internal" href="facets.html"><em>Sorting and faceting</em></a>.</p>
<div class="section" id="score-results-based-on-the-position-of-the-matched-term">
<h3>Score results based on the position of the matched term<a class="headerlink" href="#score-results-based-on-the-position-of-the-matched-term" title="Permalink to this headline">¶</a></h3>
<p>The following scoring function uses the position of the first occurance of a
term in each document to calculate the score, so documents with the given term
earlier in the document will score higher:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">whoosh</span> <span class="kn">import</span> <span class="n">scoring</span>

<span class="k">def</span> <span class="nf">pos_score_fn</span><span class="p">(</span><span class="n">searcher</span><span class="p">,</span> <span class="n">fieldname</span><span class="p">,</span> <span class="n">text</span><span class="p">,</span> <span class="n">matcher</span><span class="p">):</span>
    <span class="n">poses</span> <span class="o">=</span> <span class="n">matcher</span><span class="o">.</span><span class="n">value_as</span><span class="p">(</span><span class="s">&quot;positions&quot;</span><span class="p">)</span>
    <span class="k">return</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="p">(</span><span class="n">poses</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>

<span class="n">pos_weighting</span> <span class="o">=</span> <span class="n">scoring</span><span class="o">.</span><span class="n">FunctionWeighting</span><span class="p">(</span><span class="n">pos_score_fn</span><span class="p">)</span>
<span class="k">with</span> <span class="n">myindex</span><span class="o">.</span><span class="n">searcher</span><span class="p">(</span><span class="n">weighting</span><span class="o">=</span><span class="n">pos_weighting</span><span class="p">)</span> <span class="k">as</span> <span class="n">s</span><span class="p">:</span>
    <span class="o">...</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="results">
<h2>Results<a class="headerlink" href="#results" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-many-hits-were-there">
<h3>How many hits were there?<a class="headerlink" href="#how-many-hits-were-there" title="Permalink to this headline">¶</a></h3>
<p>The number of <em>scored</em> hits:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">found</span> <span class="o">=</span> <span class="n">results</span><span class="o">.</span><span class="n">scored_length</span><span class="p">()</span>
</pre></div>
</div>
<p>Depending on the arguments to the search, the exact total number of hits may be
known:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">if</span> <span class="n">results</span><span class="o">.</span><span class="n">has_exact_length</span><span class="p">():</span>
    <span class="k">print</span><span class="p">(</span><span class="s">&quot;Scored&quot;</span><span class="p">,</span> <span class="n">found</span><span class="p">,</span> <span class="s">&quot;of exactly&quot;</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">results</span><span class="p">),</span> <span class="s">&quot;documents&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Usually, however, the exact number of documents that match the query is not
known, because the searcher can skip over blocks of documents it knows won&#8217;t
show up in the &#8220;top N&#8221; list. If you call <tt class="docutils literal"><span class="pre">len(results)</span></tt> on a query where the
exact length is unknown, Whoosh will run an unscored version of the original
query to get the exact number. This is faster than the scored search, but may
still be noticeably slow on very large indexes or complex queries.</p>
<p>As an alternative, you might display the <em>estimated</em> total hits:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">found</span> <span class="o">=</span> <span class="n">results</span><span class="o">.</span><span class="n">scored_length</span><span class="p">()</span>
<span class="k">if</span> <span class="n">results</span><span class="o">.</span><span class="n">has_exact_length</span><span class="p">():</span>
    <span class="k">print</span><span class="p">(</span><span class="s">&quot;Scored&quot;</span><span class="p">,</span> <span class="n">found</span><span class="p">,</span> <span class="s">&quot;of exactly&quot;</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">results</span><span class="p">),</span> <span class="s">&quot;documents&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
    <span class="n">low</span> <span class="o">=</span> <span class="n">results</span><span class="o">.</span><span class="n">estimated_min_length</span><span class="p">()</span>
    <span class="n">high</span> <span class="o">=</span> <span class="n">results</span><span class="o">.</span><span class="n">estimated_length</span><span class="p">()</span>

    <span class="k">print</span><span class="p">(</span><span class="s">&quot;Scored&quot;</span><span class="p">,</span> <span class="n">found</span><span class="p">,</span> <span class="s">&quot;of between&quot;</span><span class="p">,</span> <span class="n">low</span><span class="p">,</span> <span class="s">&quot;and&quot;</span><span class="p">,</span> <span class="n">high</span><span class="p">,</span> <span class="s">&quot;documents&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="which-terms-matched-in-each-hit">
<h3>Which terms matched in each hit?<a class="headerlink" href="#which-terms-matched-in-each-hit" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Use terms=True to record term matches for each hit</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">myquery</span><span class="p">,</span> <span class="n">terms</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>

<span class="k">for</span> <span class="n">hit</span> <span class="ow">in</span> <span class="n">results</span><span class="p">:</span>
    <span class="c"># Which terms matched in this hit?</span>
    <span class="k">print</span><span class="p">(</span><span class="s">&quot;Matched:&quot;</span><span class="p">,</span> <span class="n">hit</span><span class="o">.</span><span class="n">matched_terms</span><span class="p">())</span>

    <span class="c"># Which terms from the query didn&#39;t match in this hit?</span>
    <span class="k">print</span><span class="p">(</span><span class="s">&quot;Didn&#39;t match:&quot;</span><span class="p">,</span> <span class="n">myquery</span><span class="o">.</span><span class="n">all_terms</span><span class="p">()</span> <span class="o">-</span> <span class="n">hit</span><span class="o">.</span><span class="n">matched_terms</span><span class="p">())</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="global-information">
<h2>Global information<a class="headerlink" href="#global-information" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-many-documents-are-in-the-index">
<h3>How many documents are in the index?<a class="headerlink" href="#how-many-documents-are-in-the-index" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Including documents that are deleted but not yet optimized away</span>
<span class="n">numdocs</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">doc_count_all</span><span class="p">()</span>

<span class="c"># Not including deleted documents</span>
<span class="n">numdocs</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">doc_count</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="what-fields-are-in-the-index">
<h3>What fields are in the index?<a class="headerlink" href="#what-fields-are-in-the-index" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="k">return</span> <span class="n">myindex</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">names</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="is-term-x-in-the-index">
<h3>Is term X in the index?<a class="headerlink" href="#is-term-x-in-the-index" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="k">return</span> <span class="p">(</span><span class="s">&quot;content&quot;</span><span class="p">,</span> <span class="s">&quot;wobble&quot;</span><span class="p">)</span> <span class="ow">in</span> <span class="n">searcher</span>
</pre></div>
</div>
</div>
<div class="section" id="how-many-times-does-term-x-occur-in-the-index">
<h3>How many times does term X occur in the index?<a class="headerlink" href="#how-many-times-does-term-x-occur-in-the-index" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Number of times content:wobble appears in all documents</span>
<span class="n">freq</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">frequency</span><span class="p">(</span><span class="s">&quot;content&quot;</span><span class="p">,</span> <span class="s">&quot;wobble&quot;</span><span class="p">)</span>

<span class="c"># Number of documents containing content:wobble</span>
<span class="n">docfreq</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">doc_frequency</span><span class="p">(</span><span class="s">&quot;content&quot;</span><span class="p">,</span> <span class="s">&quot;wobble&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="is-term-x-in-document-y">
<h3>Is term X in document Y?<a class="headerlink" href="#is-term-x-in-document-y" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Check if the &quot;content&quot; field of document 500 contains the term &quot;wobble&quot;</span>

<span class="c"># Without term vectors, skipping through list...</span>
<span class="n">postings</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">postings</span><span class="p">(</span><span class="s">&quot;content&quot;</span><span class="p">,</span> <span class="s">&quot;wobble&quot;</span><span class="p">)</span>
<span class="n">postings</span><span class="o">.</span><span class="n">skip_to</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>
<span class="k">return</span> <span class="n">postings</span><span class="o">.</span><span class="n">id</span><span class="p">()</span> <span class="o">==</span> <span class="mi">500</span>

<span class="c"># ...or the slower but easier way</span>
<span class="n">docset</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">searcher</span><span class="o">.</span><span class="n">postings</span><span class="p">(</span><span class="s">&quot;content&quot;</span><span class="p">,</span> <span class="s">&quot;wobble&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">all_ids</span><span class="p">())</span>
<span class="k">return</span> <span class="mi">500</span> <span class="ow">in</span> <span class="n">docset</span>

<span class="c"># If field has term vectors, skipping through list...</span>
<span class="n">vector</span> <span class="o">=</span> <span class="n">searcher</span><span class="o">.</span><span class="n">vector</span><span class="p">(</span><span class="mi">500</span><span class="p">,</span> <span class="s">&quot;content&quot;</span><span class="p">)</span>
<span class="n">vector</span><span class="o">.</span><span class="n">skip_to</span><span class="p">(</span><span class="s">&quot;wobble&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">vector</span><span class="o">.</span><span class="n">id</span><span class="p">()</span> <span class="o">==</span> <span class="s">&quot;wobble&quot;</span>

<span class="c"># ...or the slower but easier way</span>
<span class="n">wordset</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">searcher</span><span class="o">.</span><span class="n">vector</span><span class="p">(</span><span class="mi">500</span><span class="p">,</span> <span class="s">&quot;content&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">all_ids</span><span class="p">())</span>
<span class="k">return</span> <span class="s">&quot;wobble&quot;</span> <span class="ow">in</span> <span class="n">wordset</span>
</pre></div>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Whoosh recipes</a><ul>
<li><a class="reference internal" href="#general">General</a><ul>
<li><a class="reference internal" href="#get-the-stored-fields-for-a-document-from-the-document-number">Get the stored fields for a document from the document number</a></li>
</ul>
</li>
<li><a class="reference internal" href="#analysis">Analysis</a><ul>
<li><a class="reference internal" href="#eliminate-words-shorter-longer-than-n">Eliminate words shorter/longer than N</a></li>
<li><a class="reference internal" href="#allow-optional-case-sensitive-searches">Allow optional case-sensitive searches</a></li>
</ul>
</li>
<li><a class="reference internal" href="#searching">Searching</a><ul>
<li><a class="reference internal" href="#find-every-document">Find every document</a></li>
<li><a class="reference internal" href="#itunes-style-search-as-you-type">iTunes-style search-as-you-type</a></li>
</ul>
</li>
<li><a class="reference internal" href="#shortcuts">Shortcuts</a><ul>
<li><a class="reference internal" href="#look-up-documents-by-a-field-value">Look up documents by a field value</a></li>
</ul>
</li>
<li><a class="reference internal" href="#sorting-and-scoring">Sorting and scoring</a><ul>
<li><a class="reference internal" href="#score-results-based-on-the-position-of-the-matched-term">Score results based on the position of the matched term</a></li>
</ul>
</li>
<li><a class="reference internal" href="#results">Results</a><ul>
<li><a class="reference internal" href="#how-many-hits-were-there">How many hits were there?</a></li>
<li><a class="reference internal" href="#which-terms-matched-in-each-hit">Which terms matched in each hit?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#global-information">Global information</a><ul>
<li><a class="reference internal" href="#how-many-documents-are-in-the-index">How many documents are in the index?</a></li>
<li><a class="reference internal" href="#what-fields-are-in-the-index">What fields are in the index?</a></li>
<li><a class="reference internal" href="#is-term-x-in-the-index">Is term X in the index?</a></li>
<li><a class="reference internal" href="#how-many-times-does-term-x-occur-in-the-index">How many times does term X occur in the index?</a></li>
<li><a class="reference internal" href="#is-term-x-in-document-y">Is term X in document Y?</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="nested.html"
                        title="previous chapter">Indexing and searching document hierarchies</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="api/api.html"
                        title="next chapter">Whoosh API</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/recipes.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="api/api.html" title="Whoosh API"
             >next</a> |</li>
        <li class="right" >
          <a href="nested.html" title="Indexing and searching document hierarchies"
             >previous</a> |</li>
        <li><a href="index.html">Whoosh 2.5.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2007-2012 Matt Chaput.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>