You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Damjan Cvetan <da...@geneza.com.INVALID> on 2019/02/27 11:35:10 UTC

Creating custom PassageFormatter

Dear all,

For our highlighting of search hits we are moving from Original Highlighter
to Unified Highlighter but we have the need to create our own
custom PassageFormatter.

Under Original Highlighter we already have our own formatter
which implements Formatter, FormatterWithOffsetPos. This new formatter is
defined under package org.apache.solr.highlight and configured for each
core in solrconfig.xml.

Now we are trying to do the same for Unified Highlighter and as I
understand it we need to create new PassageFormatter but when we are trying
to define the new formatter and link it to the class we getting the error
"org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:
Error loading class 'solr.highlight.CustomPassageFormatter'".

Example from solrconfig.xml:
<formatter name="custom" default="false"
class="solr.highlight.CustomPassageFormatter">
</formatter>

I'm asking if this is still the right way? Is the "formatter" tag in XML
valid option for Unified Highlighter?

Thank you.

Kind regards,
  Damjan

Re: Creating custom PassageFormatter

Posted by David Smiley <da...@gmail.com>.
You've probably gotten you answer now but "no".  Basically, you'd need to
specify your own subclass of UnifiedSolrHighlighter in solrconfig.xml like
this:

<searchComponent class="solr.HighlightComponent" name="highlight">
  <highlighting class="com.acme.search.AcmeHighlighter>

  </highlighting>
</searchComponent>

I doubt there's any docs on this.

~ David


On Wed, Feb 27, 2019 at 6:35 AM Damjan Cvetan <da...@geneza.com.invalid>
wrote:

> Dear all,
>
> For our highlighting of search hits we are moving from Original Highlighter
> to Unified Highlighter but we have the need to create our own
> custom PassageFormatter.
>
> Under Original Highlighter we already have our own formatter
> which implements Formatter, FormatterWithOffsetPos. This new formatter is
> defined under package org.apache.solr.highlight and configured for each
> core in solrconfig.xml.
>
> Now we are trying to do the same for Unified Highlighter and as I
> understand it we need to create new PassageFormatter but when we are trying
> to define the new formatter and link it to the class we getting the error
> "org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:
> Error loading class 'solr.highlight.CustomPassageFormatter'".
>
> Example from solrconfig.xml:
> <formatter name="custom" default="false"
> class="solr.highlight.CustomPassageFormatter">
> </formatter>
>
> I'm asking if this is still the right way? Is the "formatter" tag in XML
> valid option for Unified Highlighter?
>
> Thank you.
>
> Kind regards,
>   Damjan
>