mirror of https://github.com/apache/lucene.git
SOLR-1696 : Deprecate old <highlighting> syntax and move configuration to HighlightComponent
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@899572 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aadfd47c8b
commit
2f81c73035
|
@ -28,6 +28,8 @@ Upgrading from Solr 1.4
|
|||
|
||||
* Using solr.xml is recommended for single cores also (SOLR-1621)
|
||||
|
||||
* Old syntax of <highlighting> is deprecated (SOLR-1696)
|
||||
|
||||
|
||||
Versions of Major Components
|
||||
---------------------
|
||||
|
@ -203,6 +205,8 @@ Other Changes
|
|||
* SOLR-1588: Removed some very old dead code.
|
||||
(Chris A. Mattmann via hossman)
|
||||
|
||||
* SOLR-1696 : Deprecate old <highlighting> syntax and move configuration to HighlightComponent (noble)
|
||||
|
||||
Build
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -928,7 +928,7 @@
|
|||
<str name="echoHandler">true</str>
|
||||
</lst>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<!-- This could most likely be commented out in the "default" case -->
|
||||
|
@ -964,6 +964,7 @@
|
|||
<!-- multi-colored tag FragmentsBuilder -->
|
||||
<fragmentsBuilder name="colored" class="org.apache.solr.highlight.MultiColoredScoreOrderFragmentsBuilder" default="true"/>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
<!-- An example dedup update processor that creates the "id" field on the fly
|
||||
based on the hash code of some other fields. This example has overwriteDupes
|
||||
|
|
|
@ -103,5 +103,6 @@ public class PluginInfo {
|
|||
for (PluginInfo child : children) if(type.equals(child.type)) result.add(child);
|
||||
return result;
|
||||
}
|
||||
public static final PluginInfo EMPTY_INFO = new PluginInfo("",Collections.<String,String>emptyMap(), new NamedList(),Collections.<PluginInfo>emptyList());
|
||||
private static final HashSet<String> NL_TAGS = new HashSet<String>(Arrays.asList("lst","str","int","bool","arr","float","double"));
|
||||
}
|
||||
|
|
|
@ -193,7 +193,12 @@ public class SolrConfig extends Config {
|
|||
loadPluginInfo(IndexDeletionPolicy.class,"mainIndex/deletionPolicy",false, true);
|
||||
loadPluginInfo(IndexReaderFactory.class,"indexReaderFactory",false, true);
|
||||
loadPluginInfo(UpdateRequestProcessorChain.class,"updateRequestProcessorChain",false, false);
|
||||
|
||||
//TODO deprecated remove it later
|
||||
loadPluginInfo(SolrHighlighter.class,"highlighting",false, false);
|
||||
if( pluginStore.containsKey( SolrHighlighter.class.getName() ) )
|
||||
log.warn( "Deprecated syntax found. <highlighting/> should move to <searchComponent/>" );
|
||||
|
||||
updateHandlerInfo = loadUpdatehandlerInfo();
|
||||
|
||||
Config.log.info("Loaded SolrConfig: " + name);
|
||||
|
|
|
@ -96,7 +96,6 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
private final UpdateHandler updateHandler;
|
||||
private final long startTime;
|
||||
private final RequestHandlers reqHandlers;
|
||||
private final SolrHighlighter highlighter;
|
||||
private final Map<String,SearchComponent> searchComponents;
|
||||
private final Map<String,UpdateRequestProcessorChain> updateProcessorChains;
|
||||
private final Map<String, SolrInfoMBean> infoRegistry;
|
||||
|
@ -463,9 +462,6 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
return createInstance(className, UpdateHandler.class, "Update Handler");
|
||||
}
|
||||
|
||||
private SolrHighlighter createHighlighter(String className) {
|
||||
return createInstance(className, SolrHighlighter.class, "Highlighter");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the last core initialized. If you are using multiple cores,
|
||||
|
@ -565,7 +561,6 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
reqHandlers = new RequestHandlers(this);
|
||||
reqHandlers.initHandlersFromConfig( solrConfig );
|
||||
|
||||
highlighter = initHighlighter();
|
||||
|
||||
// Handle things that should eventually go away
|
||||
initDeprecatedSupport();
|
||||
|
@ -615,19 +610,6 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
resourceLoader.inform(infoRegistry);
|
||||
}
|
||||
|
||||
private SolrHighlighter initHighlighter() {
|
||||
SolrHighlighter highlighter = null;
|
||||
PluginInfo pluginInfo = solrConfig.getPluginInfo(SolrHighlighter.class.getName());
|
||||
if(pluginInfo != null){
|
||||
highlighter = createInitInstance(pluginInfo,SolrHighlighter.class,null, DefaultSolrHighlighter.class.getName());
|
||||
highlighter.initalize(solrConfig);
|
||||
} else{
|
||||
highlighter = new DefaultSolrHighlighter();
|
||||
highlighter.initalize(solrConfig);
|
||||
}
|
||||
return highlighter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the request processors
|
||||
|
@ -805,8 +787,10 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
/**
|
||||
* Get the SolrHighlighter
|
||||
*/
|
||||
@Deprecated
|
||||
public SolrHighlighter getHighlighter() {
|
||||
return highlighter;
|
||||
HighlightComponent hl = (HighlightComponent) searchComponents.get(HighlightComponent.COMPONENT_NAME);
|
||||
return hl==null? null: hl.getHighlighter();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -838,10 +822,20 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
{
|
||||
Map<String, SearchComponent> components = new HashMap<String, SearchComponent>();
|
||||
initPlugins(components,SearchComponent.class);
|
||||
for (Map.Entry<String, SearchComponent> e : components.entrySet()) {
|
||||
SearchComponent c = e.getValue();
|
||||
if (c instanceof HighlightComponent) {
|
||||
HighlightComponent hl = (HighlightComponent) c;
|
||||
if(!HighlightComponent.COMPONENT_NAME.equals(e.getKey())){
|
||||
components.put(HighlightComponent.COMPONENT_NAME,hl);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
addIfNotPresent(components,HighlightComponent.COMPONENT_NAME,HighlightComponent.class);
|
||||
addIfNotPresent(components,QueryComponent.COMPONENT_NAME,QueryComponent.class);
|
||||
addIfNotPresent(components,FacetComponent.COMPONENT_NAME,FacetComponent.class);
|
||||
addIfNotPresent(components,MoreLikeThisComponent.COMPONENT_NAME,MoreLikeThisComponent.class);
|
||||
addIfNotPresent(components,HighlightComponent.COMPONENT_NAME,HighlightComponent.class);
|
||||
addIfNotPresent(components,StatsComponent.COMPONENT_NAME,StatsComponent.class);
|
||||
addIfNotPresent(components,DebugComponent.COMPONENT_NAME,DebugComponent.class);
|
||||
return components;
|
||||
|
|
|
@ -25,12 +25,18 @@ import org.apache.solr.common.params.SolrParams;
|
|||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.highlight.SolrHighlighter;
|
||||
import org.apache.solr.highlight.DefaultSolrHighlighter;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.util.plugin.PluginInfoInitialized;
|
||||
import org.apache.solr.util.plugin.SolrCoreAware;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* TODO!
|
||||
|
@ -38,22 +44,44 @@ import java.util.Map;
|
|||
* @version $Id$
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class HighlightComponent extends SearchComponent
|
||||
public class HighlightComponent extends SearchComponent implements PluginInfoInitialized, SolrCoreAware
|
||||
{
|
||||
public static final String COMPONENT_NAME = "highlight";
|
||||
private PluginInfo info = PluginInfo.EMPTY_INFO;
|
||||
private SolrHighlighter highlighter;
|
||||
|
||||
|
||||
public void init(PluginInfo info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(ResponseBuilder rb) throws IOException
|
||||
{
|
||||
SolrHighlighter highlighter = rb.req.getCore().getHighlighter();
|
||||
public void prepare(ResponseBuilder rb) throws IOException {
|
||||
rb.doHighlights = highlighter.isHighlightingEnabled(rb.req.getParams());
|
||||
}
|
||||
|
||||
public void inform(SolrCore core) {
|
||||
List<PluginInfo> children = info.getChildren("highlighting");
|
||||
if(children.isEmpty()) {
|
||||
PluginInfo pluginInfo = core.getSolrConfig().getPluginInfo(SolrHighlighter.class.getName()); //TODO deprecated configuration remove later
|
||||
if (pluginInfo != null) {
|
||||
highlighter = core.createInitInstance(pluginInfo, SolrHighlighter.class, null, DefaultSolrHighlighter.class.getName());
|
||||
highlighter.initalize(core.getSolrConfig());
|
||||
} else {
|
||||
DefaultSolrHighlighter defHighlighter = new DefaultSolrHighlighter(core);
|
||||
defHighlighter.init(PluginInfo.EMPTY_INFO);
|
||||
highlighter = defHighlighter;
|
||||
}
|
||||
} else {
|
||||
highlighter = core.createInitInstance(children.get(0),SolrHighlighter.class,null, DefaultSolrHighlighter.class.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ResponseBuilder rb) throws IOException {
|
||||
SolrQueryRequest req = rb.req;
|
||||
if (rb.doHighlights) {
|
||||
SolrHighlighter highlighter = req.getCore().getHighlighter();
|
||||
SolrParams params = req.getParams();
|
||||
|
||||
String[] defaultHighlightFields; //TODO: get from builder by default?
|
||||
|
@ -158,6 +186,9 @@ public class HighlightComponent extends SearchComponent
|
|||
return nl;
|
||||
}
|
||||
|
||||
public SolrHighlighter getHighlighter() {
|
||||
return highlighter;
|
||||
}
|
||||
////////////////////////////////////////////
|
||||
/// SolrInfoMBean
|
||||
////////////////////////////////////////////
|
||||
|
|
|
@ -353,7 +353,7 @@
|
|||
<str>spellcheck</str>
|
||||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -376,6 +376,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -362,6 +362,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -384,6 +385,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -378,6 +378,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -400,7 +401,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
|
||||
</searchComponent>
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
<requestDispatcher handleSelect="true" >
|
||||
|
|
|
@ -375,6 +375,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -397,6 +398,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -365,6 +365,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -387,6 +388,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -357,6 +357,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -379,7 +380,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
|
||||
</searchComponent>
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
<requestDispatcher handleSelect="true" >
|
||||
|
|
|
@ -266,6 +266,7 @@
|
|||
<requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
|
||||
<requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy" />
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -288,7 +289,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
|
||||
</searchComponent>
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
<requestDispatcher handleSelect="true" >
|
||||
|
|
|
@ -301,7 +301,7 @@
|
|||
|
||||
<requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
|
||||
<requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy" />
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting class="org.apache.solr.highlight.DummyHighlighter">
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -324,6 +324,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -397,6 +397,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -419,6 +420,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -266,6 +266,7 @@
|
|||
<requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
|
||||
<requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy" />
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -288,7 +289,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
|
||||
</searchComponent>
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
<requestDispatcher handleSelect="true" >
|
||||
|
|
|
@ -407,6 +407,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -429,7 +430,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
|
||||
</searchComponent>
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
<requestDispatcher handleSelect="true" >
|
||||
|
|
|
@ -407,6 +407,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -429,6 +430,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -394,6 +394,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -416,6 +417,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -371,6 +371,7 @@
|
|||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -393,6 +394,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -396,7 +396,7 @@
|
|||
<str>tvComponent</str>
|
||||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
|
||||
|
@ -427,6 +427,7 @@
|
|||
|
||||
<fragmentsBuilder name="scoreOrder" class="org.apache.solr.highlight.ScoreOrderFragmentsBuilder" default="true"/>
|
||||
</highlighting>
|
||||
</searchComponent>
|
||||
|
||||
|
||||
<!-- enable streaming for testing... -->
|
||||
|
|
|
@ -763,6 +763,7 @@
|
|||
</lst>
|
||||
</requestHandler>
|
||||
|
||||
<searchComponent class="solr.HighlightComponent" name="highlight">
|
||||
<highlighting>
|
||||
<!-- Configure the standard fragmenter -->
|
||||
<!-- This could most likely be commented out in the "default" case -->
|
||||
|
@ -792,7 +793,7 @@
|
|||
</lst>
|
||||
</formatter>
|
||||
</highlighting>
|
||||
|
||||
</searchComponent>
|
||||
<!-- An example dedup update processor that creates the "id" field on the fly
|
||||
based on the hash code of some other fields. This example has overwriteDupes
|
||||
set to false since we are using the id field as the signatureField and Solr
|
||||
|
|
Loading…
Reference in New Issue