📄 package.html
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head></head><body>The calculus of spans.<p>A span is a <code><doc,startPosition,endPosition></code> tuple.</p><p>The following span query operators are implemented:<ul><li>A <a href="SpanTermQuery.html">SpanTermQuery</a> matches all spanscontaining a particular <a href="../../index/Term.html">Term</a>.</li><li> A <a href="SpanNearQuery.html">SpanNearQuery</a> matches spanswhich occur near one another, and can be used to implement things likephrase search (when constructed from <ahref="SpanTermQuery.html">SpanTermQueries</a>) and inter-phraseproximity (when constructed from other <ahref="SpanNearQuery.html">SpanNearQueries</a>).</li><li>A <a href="SpanOrQuery.html">SpanOrQuery</a> merges spans from anumber of other <a href="SpanQuery.html">SpanQueries</a>.</li><li>A <a href="SpanNotQuery.html">SpanNotQuery</a> removes spansmatching one <a href="SpanQuery.html">SpanQuery</a> which overlapanother. This can be used, e.g., to implement within-paragraphsearch.</li><li>A <a href="SpanFirstQuery.html">SpanFirstQuery</a> matches spansmatching <code>q</code> whose end position is less than<code>n</code>. This can be used to constrain matches to the firstpart of the document.</li></ul>In all cases, output spans are minimally inclusive. In other words, aspan formed by matching a span in x and y starts at the lesser of thetwo starts and ends at the greater of the two ends.</p><p>For example, a span query which matches "John Kerry" within tenwords of "George Bush" within the first 100 words of the documentcould be constructed with:<pre>SpanQuery john = new SpanTermQuery(new Term("content", "john"));SpanQuery kerry = new SpanTermQuery(new Term("content", "kerry"));SpanQuery george = new SpanTermQuery(new Term("content", "george"));SpanQuery bush = new SpanTermQuery(new Term("content", "bush"));SpanQuery johnKerry = new SpanNearQuery(new SpanQuery[] {john, kerry}, 0, true);SpanQuery georgeBush = new SpanNearQuery(new SpanQuery[] {george, bush}, 0, true);SpanQuery johnKerryNearGeorgeBush = new SpanNearQuery(new SpanQuery[] {johnKerry, georgeBush}, 10, false);SpanQuery johnKerryNearGeorgeBushAtStart = new SpanFirstQuery(johnKerryNearGeorgeBush, 100);</pre><p>Span queries may be freely intermixed with other Lucene queries.So, for example, the above query can be restricted to documents whichalso use the word "iraq" with:<pre>Query query = new BooleanQuery();query.add(johnKerryNearGeorgeBushAtStart, true, false);query.add(new TermQuery("content", "iraq"), true, false);</pre></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -