Phrasequery to make researches
<p>Is there anyway to use phrasequery with python?
until now i was using parser, but i would like to know how to use phrasequery.</p>

<pre><code>parser = QueryParser(Version.LUCENE_CURRENT, "contents",
                        analyzer)
parser.setDefaultOperator(QueryParser.Operator.AND)
query = parser.parse(command)
    scoreDocs = searcher.search(query, 10000).scoreDocs
</code></pre>

<p>Firstly, you should understand that when you cut out the QueryParser, you lose the analyzer.  <code>PhraseQuery</code> won't analyze for you, like the QueryParser does, so it's on you to tokenize and normalize your phrase to match the index-time analysis.  You may be better off sticking with the parser.</p>

<p>That said, constructing a PhraseQuery manually looks something like this:</p>

<pre><code>query = PhraseQuery()
query.add(Term("contents", "lorem"))
query.add(Term("contents", "ipsum"))
query.add(Term("contents", "sit"))
query.add(Term("contents", "amet"))
</code></pre>

<p>You can set the slop for the query using <code>setSlop</code>.</p>

<p>You can also specify the position of each term.  For instance, if "sit" were a stopword in my index, I might do something like:</p>

<pre><code>query = PhraseQuery()
query.add(Term("contents", "lorem"), 0)
query.add(Term("contents", "ipsum"), 1)
query.add(Term("contents", "amet"), 3)
</code></pre>

python lucene