lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject svn commit: r1651079 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/highlight/ solr/core/src/test-files/solr/collection1/conf/ solr/core/src/test/org/apache/solr/highlight/ solr/solrj/ solr/solrj/src/java/or...
Date Mon, 12 Jan 2015 13:33:51 GMT
Author: dsmiley
Date: Mon Jan 12 13:33:50 2015
New Revision: 1651079

URL: http://svn.apache.org/r1651079
Log:
SOLR-6916: hl.payloads

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
    lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/schema.xml
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
    lucene/dev/branches/branch_5x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1651079&r1=1651078&r2=1651079&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Mon Jan 12 13:33:50 2015
@@ -171,7 +171,7 @@ New Features
 * SOLR-6605: Make ShardHandlerFactory maxConnections configurable.
   (Christine Poerschke via shalin)
 
-* SOLR-6585: RequestHandlers can optionaly handle sub paths as well (Noble Paul)
+* SOLR-6585: RequestHandlers can optionally handle sub paths as well (Noble Paul)
 
 * SOLR-6617: /update/json/docs path will use fully qualified node names by default
              (Noble Paul)
@@ -245,6 +245,9 @@ New Features
 
 * SOLR-2035: Add a VelocityResponseWriter $resource tool for locale-specific string lookups.
   (Erik Hatcher)
+
+* SOLR-6916: Toggle payload support for the default highlighter via hl.payloads.  It's auto
+  enabled when the index has payloads. (David Smiley)
   
 
 Bug Fixes

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java?rev=1651079&r1=1651078&r2=1651079&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java
Mon Jan 12 13:33:50 2015
@@ -240,16 +240,11 @@ public class DefaultSolrHighlighter exte
    * @param request The SolrQueryRequest
    */
   private QueryScorer getSpanQueryScorer(Query query, String fieldName, TokenStream tokenStream,
SolrQueryRequest request) {
-    boolean reqFieldMatch = request.getParams().getFieldBool(fieldName, HighlightParams.FIELD_MATCH,
false);
-    boolean highlightMultiTerm = request.getParams().getBool(HighlightParams.HIGHLIGHT_MULTI_TERM,
true);
-    QueryScorer scorer;
-    if (reqFieldMatch) {
-      scorer = new QueryScorer(query, fieldName);
-    }
-    else {
-      scorer = new QueryScorer(query, null);
-    }
-    scorer.setExpandMultiTermQuery(highlightMultiTerm);
+    QueryScorer scorer = new QueryScorer(query,
+        request.getParams().getFieldBool(fieldName, HighlightParams.FIELD_MATCH, false) ?
fieldName : null);
+    scorer.setExpandMultiTermQuery(request.getParams().getBool(HighlightParams.HIGHLIGHT_MULTI_TERM,
true));
+    scorer.setUsePayloads(request.getParams().getFieldBool(fieldName, HighlightParams.PAYLOADS,
+        request.getSearcher().getLeafReader().getFieldInfos().fieldInfo(fieldName).hasPayloads()));
     return scorer;
   }
 
@@ -608,7 +603,7 @@ public class DefaultSolrHighlighter exte
       if (summaries.length > 0) 
       docSummaries.add(fieldName, summaries);
     }
-    // no summeries made, copy text from alternate field
+    // no summaries made, copy text from alternate field
     if (summaries == null || summaries.length == 0) {
       alternateField( docSummaries, params, doc, fieldName );
     }

Modified: lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/schema.xml?rev=1651079&r1=1651078&r2=1651079&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/schema.xml
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/collection1/conf/schema.xml
Mon Jan 12 13:33:50 2015
@@ -401,6 +401,16 @@
     </analyzer>
   </fieldType>
 
+  <fieldType name="payloadDelimited" class="solr.TextField">
+    <analyzer type="index">
+      <tokenizer class="solr.WhitespaceTokenizerFactory" />
+      <filter class="solr.DelimitedPayloadTokenFilterFactory" encoder="integer" />
+    </analyzer>
+    <analyzer type="query">
+      <tokenizer class="solr.WhitespaceTokenizerFactory" />
+    </analyzer>
+  </fieldType>
+
 </types>
 
 
@@ -536,6 +546,8 @@
    <field name="lower" type="lowertok" indexed="false" stored="true" multiValued="true"
/>
    <field name="_route_" type="string" indexed="true" stored="true" multiValued="false"
/>
 
+   <field name="payloadDelimited" type="payloadDelimited" />
+
    <!-- Dynamic field definitions.  If a field name is not found, dynamicFields
         will be used if the name matches any of the patterns.
         RESTRICTION: the glob-like pattern in the name attribute must have

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java?rev=1651079&r1=1651078&r2=1651079&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
Mon Jan 12 13:33:50 2015
@@ -17,17 +17,27 @@
 
 package org.apache.solr.highlight;
 
+import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.spans.SpanPayloadCheckQuery;
+import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.HighlightParams;
 import org.apache.solr.handler.component.HighlightComponent;
+import org.apache.solr.handler.component.ResponseBuilder;
+import org.apache.solr.handler.component.SearchComponent;
 import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.search.DocSet;
 import org.apache.solr.util.TestHarness;
 import org.junit.After;
 import org.junit.BeforeClass;
@@ -1053,4 +1063,37 @@ public class HighlighterTest extends Sol
     );
 
   }
+
+  @Test
+  public void payloadFilteringSpanQuery() throws IOException {
+    clearIndex();
+
+    String FIELD_NAME = "payloadDelimited";
+    assertU(adoc("id", "0", FIELD_NAME, "word|7 word|2"));
+    assertU(commit());
+
+    //We search at a lower level than typical Solr tests because there's no QParser for payloads
+
+    //Create query matching this payload
+    Query query = new SpanPayloadCheckQuery(new SpanTermQuery(new Term(FIELD_NAME, "word")),
+        Collections.singleton(new byte[]{0,0,0,7}));//bytes for integer 7
+
+    //invoke highlight component... the hard way
+    final SearchComponent hlComp = h.getCore().getSearchComponent("highlight");
+    SolrQueryRequest req = req("hl", "true", "hl.fl", FIELD_NAME, HighlightParams.USE_PHRASE_HIGHLIGHTER,
"true");
+    try {
+      SolrQueryResponse resp = new SolrQueryResponse();
+      ResponseBuilder rb = new ResponseBuilder(req, resp, Collections.singletonList(hlComp));
+      rb.setHighlightQuery(query);
+      rb.setResults(req.getSearcher().getDocListAndSet(query, (DocSet) null, null, 0, 1));
+      //highlight:
+      hlComp.prepare(rb);
+      hlComp.process(rb);
+      //inspect response
+      final String[] snippets = (String[]) resp.getValues().findRecursive("highlighting",
"0", FIELD_NAME);
+      assertEquals("<em>word|7</em> word|2", snippets[0]);
+    } finally {
+      req.close();
+    }
+  }
 }

Modified: lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java?rev=1651079&r1=1651078&r2=1651079&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java
(original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java
Mon Jan 12 13:33:50 2015
@@ -52,6 +52,7 @@ public interface HighlightParams {
   
   public static final String USE_PHRASE_HIGHLIGHTER = HIGHLIGHT+".usePhraseHighlighter";
   public static final String HIGHLIGHT_MULTI_TERM = HIGHLIGHT+".highlightMultiTerm";
+  public static final String PAYLOADS = HIGHLIGHT+".payloads";
 
   public static final String MERGE_CONTIGUOUS_FRAGMENTS = HIGHLIGHT + ".mergeContiguous";
 



Mime
View raw message