mirror of https://github.com/apache/lucene.git
SOLR-2049: add hl.multiValuedSeparatorChar for FVH
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@986773 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8344ddee1
commit
b573c16001
|
@ -226,6 +226,8 @@ New Features
|
|||
|
||||
* SOLR-2053: Add support for custom comparators in Solr spellchecker, per LUCENE-2479 (gsingers)
|
||||
|
||||
* SOLR-2049: Add hl.multiValuedSeparatorChar for FastVectorHighlighter, per LUCENE-2603. (koji)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -1032,7 +1032,13 @@
|
|||
<fragListBuilder name="single" class="org.apache.solr.highlight.SingleFragListBuilder"/>
|
||||
|
||||
<!-- default tag FragmentsBuilder -->
|
||||
<fragmentsBuilder name="default" class="org.apache.solr.highlight.ScoreOrderFragmentsBuilder" default="true"/>
|
||||
<fragmentsBuilder name="default" class="org.apache.solr.highlight.ScoreOrderFragmentsBuilder" default="true">
|
||||
<!--
|
||||
<lst name="defaults">
|
||||
<str name="hl.multiValuedSeparatorChar">/</str>
|
||||
</lst>
|
||||
-->
|
||||
</fragmentsBuilder>
|
||||
|
||||
<!-- multi-colored tag FragmentsBuilder -->
|
||||
<fragmentsBuilder name="colored" class="org.apache.solr.highlight.ScoreOrderFragmentsBuilder">
|
||||
|
|
|
@ -45,6 +45,7 @@ public interface HighlightParams {
|
|||
public static final String USE_FVH = HIGHLIGHT + ".useFastVectorHighlighter";
|
||||
public static final String TAG_PRE = HIGHLIGHT + ".tag.pre";
|
||||
public static final String TAG_POST = HIGHLIGHT + ".tag.post";
|
||||
public static final String MULTI_VALUED_SEPARATOR = HIGHLIGHT + ".multiValuedSeparatorChar";
|
||||
|
||||
// Formatter
|
||||
public static final String SIMPLE = "simple";
|
||||
|
|
|
@ -18,13 +18,17 @@
|
|||
package org.apache.solr.highlight;
|
||||
|
||||
import org.apache.lucene.search.vectorhighlight.FragmentsBuilder;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
|
||||
public class ScoreOrderFragmentsBuilder extends SolrFragmentsBuilder {
|
||||
|
||||
@Override
|
||||
protected FragmentsBuilder getFragmentsBuilder(String[] preTags,
|
||||
String[] postTags) {
|
||||
return new org.apache.lucene.search.vectorhighlight.ScoreOrderFragmentsBuilder( preTags, postTags );
|
||||
protected FragmentsBuilder getFragmentsBuilder( SolrParams params,
|
||||
String[] preTags, String[] postTags ) {
|
||||
org.apache.lucene.search.vectorhighlight.ScoreOrderFragmentsBuilder sofb =
|
||||
new org.apache.lucene.search.vectorhighlight.ScoreOrderFragmentsBuilder( preTags, postTags );
|
||||
sofb.setMultiValuedSeparator( getMultiValuedSeparatorChar( params ) );
|
||||
return sofb;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -18,13 +18,17 @@
|
|||
package org.apache.solr.highlight;
|
||||
|
||||
import org.apache.lucene.search.vectorhighlight.FragmentsBuilder;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
|
||||
public class SimpleFragmentsBuilder extends SolrFragmentsBuilder {
|
||||
|
||||
@Override
|
||||
protected FragmentsBuilder getFragmentsBuilder(String[] preTags,
|
||||
String[] postTags) {
|
||||
return new org.apache.lucene.search.vectorhighlight.SimpleFragmentsBuilder( preTags, postTags );
|
||||
protected FragmentsBuilder getFragmentsBuilder( SolrParams params,
|
||||
String[] preTags, String[] postTags ) {
|
||||
org.apache.lucene.search.vectorhighlight.SimpleFragmentsBuilder sfb =
|
||||
new org.apache.lucene.search.vectorhighlight.SimpleFragmentsBuilder( preTags, postTags );
|
||||
sfb.setMultiValuedSeparator( getMultiValuedSeparatorChar( params ) );
|
||||
return sfb;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.solr.highlight;
|
||||
|
||||
import org.apache.lucene.search.vectorhighlight.FragmentsBuilder;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.DefaultSolrParams;
|
||||
import org.apache.solr.common.params.HighlightParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
|
@ -39,7 +40,10 @@ public abstract class SolrFragmentsBuilder extends HighlightingPluginBase
|
|||
*/
|
||||
public FragmentsBuilder getFragmentsBuilder(SolrParams params) {
|
||||
numRequests++;
|
||||
return getFragmentsBuilder( getPreTags( params, null ), getPostTags( params, null ) );
|
||||
if( defaults != null ) {
|
||||
params = new DefaultSolrParams( params, defaults );
|
||||
}
|
||||
return getFragmentsBuilder( params, getPreTags( params, null ), getPostTags( params, null ) );
|
||||
}
|
||||
|
||||
public String[] getPreTags( SolrParams params, String fieldName ){
|
||||
|
@ -66,5 +70,14 @@ public abstract class SolrFragmentsBuilder extends HighlightingPluginBase
|
|||
return tags;
|
||||
}
|
||||
|
||||
protected abstract FragmentsBuilder getFragmentsBuilder( String[] preTags, String[] postTags );
|
||||
protected abstract FragmentsBuilder getFragmentsBuilder( SolrParams params, String[] preTags, String[] postTags );
|
||||
|
||||
protected char getMultiValuedSeparatorChar( SolrParams params ){
|
||||
String separator = params.get( HighlightParams.MULTI_VALUED_SEPARATOR, " " );
|
||||
if( separator.length() > 1 ){
|
||||
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
|
||||
HighlightParams.MULTI_VALUED_SEPARATOR + " parameter must be a char, but is \"" + separator + "\"" );
|
||||
}
|
||||
return separator.charAt( 0 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue