lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject lucene-solr:branch_6x: LUCENE-7293: don't try to highlight GeoPoint queries
Date Fri, 20 May 2016 18:49:49 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 0132d58e5 -> 78e92a053


LUCENE-7293: don't try to highlight GeoPoint queries


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/78e92a05
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/78e92a05
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/78e92a05

Branch: refs/heads/branch_6x
Commit: 78e92a05365b6642f3c880b0fefaedf4102c6457
Parents: 0132d58
Author: Mike McCandless <mikemccand@apache.org>
Authored: Fri May 20 14:48:35 2016 -0400
Committer: Mike McCandless <mikemccand@apache.org>
Committed: Fri May 20 14:49:05 2016 -0400

----------------------------------------------------------------------
 lucene/CHANGES.txt                              |  3 ++
 lucene/highlighter/build.xml                    |  3 +-
 .../highlight/WeightedSpanTermExtractor.java    |  5 ++-
 .../search/highlight/HighlighterTest.java       | 32 +++++++++++++++++---
 4 files changed, 37 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/78e92a05/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 8936ff9..772a44c 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -117,6 +117,9 @@ Bug Fixes
 * LUCENE-7231: WeightedSpanTermExtractor didn't deal correctly with single-term
   phrase queries. (Eva Popenda, Alan Woodward)
 
+* LUCENE-7293: Don't try to highlight GeoPoint queries (Britta Weber,
+  Nick Knize, Mike McCandless)
+
 Documentation
 
 * LUCENE-7223: Improve XXXPoint javadocs to make it clear that you

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/78e92a05/lucene/highlighter/build.xml
----------------------------------------------------------------------
diff --git a/lucene/highlighter/build.xml b/lucene/highlighter/build.xml
index e0dfa7e..e706b99 100644
--- a/lucene/highlighter/build.xml
+++ b/lucene/highlighter/build.xml
@@ -31,12 +31,13 @@
   <path id="classpath">
     <pathelement path="${memory.jar}"/>
     <pathelement path="${queries.jar}"/>
+    <pathelement path="${spatial.jar}"/>
     <pathelement path="${join.jar}"/>
     <pathelement path="${analyzers-common.jar}"/>
     <path refid="base.classpath"/>
   </path>
 
-  <target name="compile-core" depends="jar-memory,jar-queries,jar-join,jar-analyzers-common,common.compile-core"
/>
+  <target name="compile-core" depends="jar-memory,jar-spatial,jar-queries,jar-join,jar-analyzers-common,common.compile-core"
/>
 
   <target name="javadocs" depends="javadocs-memory,compile-core,check-javadocs-uptodate"
           unless="javadocs-uptodate-${name}">

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/78e92a05/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
----------------------------------------------------------------------
diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
b/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
index 89cbd11..14acb9d 100644
--- a/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
+++ b/lucene/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
@@ -62,9 +62,10 @@ import org.apache.lucene.search.spans.SpanNearQuery;
 import org.apache.lucene.search.spans.SpanNotQuery;
 import org.apache.lucene.search.spans.SpanOrQuery;
 import org.apache.lucene.search.spans.SpanQuery;
-import org.apache.lucene.search.spans.Spans;
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.search.spans.SpanWeight;
+import org.apache.lucene.search.spans.Spans;
+import org.apache.lucene.spatial.geopoint.search.GeoPointInBBoxQuery;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.IOUtils;
 
@@ -211,6 +212,8 @@ public class WeightedSpanTermExtractor {
       //nothing
     } else if (query instanceof CustomScoreQuery){
       extract(((CustomScoreQuery) query).getSubQuery(), boost, terms);
+    } else if (query instanceof GeoPointInBBoxQuery) {
+      // nothing
     } else {
       Query origQuery = query;
       final IndexReader reader = getLeafContext().reader();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/78e92a05/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
----------------------------------------------------------------------
diff --git a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
index 0a034f1..c6dc863 100644
--- a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
+++ b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
@@ -16,8 +16,6 @@
  */
 package org.apache.lucene.search.highlight;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -29,6 +27,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
@@ -53,21 +53,22 @@ import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queries.CommonTermsQuery;
 import org.apache.lucene.queries.CustomScoreQuery;
 import org.apache.lucene.queries.payloads.SpanPayloadCheckQuery;
 import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.ConstantScoreQuery;
 import org.apache.lucene.search.FuzzyQuery;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.MultiPhraseQuery;
 import org.apache.lucene.search.MultiTermQuery;
-import org.apache.lucene.search.PhraseQuery;
 import org.apache.lucene.search.PhraseQuery.Builder;
+import org.apache.lucene.search.PhraseQuery;
 import org.apache.lucene.search.PrefixQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.RegexpQuery;
@@ -87,6 +88,7 @@ import org.apache.lucene.search.spans.SpanNotQuery;
 import org.apache.lucene.search.spans.SpanOrQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
+import org.apache.lucene.spatial.geopoint.search.GeoPointInBBoxQuery;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
@@ -163,6 +165,28 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements
Formatte
 
   }
 
+  public void testGeoPointQueryHighlight() throws Exception {
+    BooleanQuery boolQuery = new BooleanQuery.Builder().add(
+        new BooleanClause(new GeoPointInBBoxQuery("geo_point", -64.92354174306496
+            , 61.10078883158897, -170.15625, 118.47656249999999), BooleanClause.Occur.SHOULD)).add(
+        new BooleanClause(new TermQuery(new Term(FIELD_NAME, "instances")), BooleanClause.Occur.SHOULD)).build();
+    CustomScoreQuery query = new CustomScoreQuery(boolQuery);
+
+    searcher = newSearcher(reader);
+    TopDocs hits = searcher.search(query, 10);
+    QueryScorer scorer = new QueryScorer(query, FIELD_NAME);
+    Highlighter highlighter = new Highlighter(scorer);
+
+    final int docId0 = hits.scoreDocs[0].doc;
+    Document doc = searcher.doc(docId0);
+    String storedField = doc.get(FIELD_NAME);
+
+    TokenStream stream = getAnyTokenStream(FIELD_NAME, docId0);
+    Fragmenter fragmenter = new SimpleSpanFragmenter(scorer);
+    highlighter.setTextFragmenter(fragmenter);
+    highlighter.getBestFragment(stream, storedField);
+  }
+
   public void testQueryScorerHits() throws Exception {
     PhraseQuery phraseQuery = new PhraseQuery(FIELD_NAME, "very", "long");
 


Mime
View raw message