You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Luc Vanlerberghe (JIRA)" <ji...@apache.org> on 2015/03/12 17:51:38 UTC

[jira] [Commented] (SOLR-6070) Cannot use multiple highlighting components in a single solrconfig

    [ https://issues.apache.org/jira/browse/SOLR-6070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14358957#comment-14358957 ] 

Luc Vanlerberghe commented on SOLR-6070:
----------------------------------------

I also tried using different highlighters for two different requestHandlers.

It turns out that as soon as a HighlightComponent is defined in the solrConfig.xml it is automatically also used as the default HighlightComponent.
i.e: If you define a highlight component as a searchComponent with name "customHighlighter", it will automatically be used for the name "hightlight" as well.
A workaround is to define the default highlighter explicitly *after* your definition with the default "highlight" name like this:
{code}
  <searchComponent class="solr.HighlightComponent" name="highlight"/>
{code}

The culprit is indeed in the loadSearchComponents method in SolrCore.java which special cases components that are instanceof HighlightComponent to automatically register using the "highlight" name as well.

{code}
    for (String name : searchComponents.keySet()) {
      if (searchComponents.isLoaded(name) && searchComponents.get(name) instanceof HighlightComponent) {
        if (!HighlightComponent.COMPONENT_NAME.equals(name)) {
          searchComponents.put(HighlightComponent.COMPONENT_NAME, searchComponents.getRegistry().get(name));
        }
        break;
      }
    }
{code}

This code was introduced as part of SOLR-1696 probably to maintain backwards compatibility and still persists today (see the commits for SOLR-7073 where it was updated but not removed)

I would be strongly in favor of removing this special case for HighlighterComponent (perhaps depending on the luceneMatchVersion of the solrconfig.xml file)
As a minimum, it should be mentioned in the docs for solrconfig.xml somewhere


> Cannot use multiple highlighting components in a single solrconfig
> ------------------------------------------------------------------
>
>                 Key: SOLR-6070
>                 URL: https://issues.apache.org/jira/browse/SOLR-6070
>             Project: Solr
>          Issue Type: Bug
>          Components: highlighter
>    Affects Versions: 4.7.2, 4.8
>            Reporter: Elaine Cario
>              Labels: highlighting
>
> I'm trying to use both the PostingsHighlighter and the FastVectorHighlighter in the same solrconfig (selection driven by different request handlers), but once I define 2 search components in the config, it always picks the Postings Highlighter (even if I never reference it in any request handler).
> I think the culprit is some specific code in SolrCore.loadSearchComponents(), which overwrites the "highlighting" component with the contents of the "postingshighlight" component - so the components map has 2 entries, but they both point to the same highlighting class (the PostingsHighlighter).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org