From 45c5ec4577160978024806454d835d0dafdb10d7 Mon Sep 17 00:00:00 2001 From: Doug Cutting Date: Tue, 30 Mar 2004 20:33:25 +0000 Subject: [PATCH] Improved javadoc for span queries. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150276 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/search/spans/package.html | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/java/org/apache/lucene/search/spans/package.html b/src/java/org/apache/lucene/search/spans/package.html index ee9b3465e27..f23fc7e0afd 100644 --- a/src/java/org/apache/lucene/search/spans/package.html +++ b/src/java/org/apache/lucene/search/spans/package.html @@ -3,5 +3,74 @@ The calculus of spans. + +

A span is a <doc,startPosition,endPosition> tuple.

+ +

The following span query operators are implemented: + +

+ +In all cases, output spans are minimally inclusive. In other words, a +span formed by matching a span in x and y starts at the lesser of the +two starts and ends at the greater of the two ends. +

+ +

For example, a span query which matches "John Kerry" within ten +words of "George Bush" within the first 100 words of the document +could be constructed with: +

+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);
+
+ +

Span queries may be freely intermixed with other Lucene queries. +So, for example, the above query can be restricted to documents which +also use the word "iraq" with: + +

+Query query = new BooleanQuery();
+query.add(johnKerryNearGeorgeBushAtStart, true, false);
+query.add(new TermQuery("content", "iraq"), true, false);
+
+