If you already have highlighting defined from one of the default
configsets, you can see an example of how the JSON is structured with
a Config API request. I assume you already tried that, but pointing it
out just in case.

Defining a highlighter with the Config API is a bit confusing to be
honest, but I worked out something that works:

{"add-searchcomponent": {"highlight": {"name":"myHighlight",
"class":"solr.HighlightComponent","": {"gap": {"default":"true",
"name": "gap", "class":"solr.highlight.GapFragmenter",
"defaults":{"hl.fragsize":100}}},"html":[{"default": "true","name":
"html","class": "solr.highlight.HtmlFormatter","defaults":
{"hl.simple.pre":"<![CDATA[<em>]]>",
"hl.simple.post":"<![CDATA[</em>]]>"}},{"name": "html","class":
"solr.highlight.HtmlEncoder"}]}}}

Note there is an empty string after the initial class definition
(shown as ""). That lets you then add the fragmenters.

(I tried to prettify that, but my mail client isn't cooperating. I'm
going to add this example to the Solr Ref Guide, though so it might be
easier to see there in a few minutes.)

Hope it helps -
Cassandra

On Wed, Jun 29, 2016 at 8:00 AM, Alexandre Drouin
<alexandre.dro...@orckestra.com> wrote:
> Hi,
>
> I'm trying to create a highlight search component using the Config API of 
> Solr 6.0.1 however I cannot figure out how to include the elements 
> fragmenter, formatter, encoder, etc...
>
> Let's say I have the following component:
>
>   <searchComponent class="solr.HighlightComponent" 
> name="myHighlightingComponent">
>     <highlighting>
>       <fragmenter name="gap" default="true" 
> class="solr.highlight.GapFragmenter">
>         <lst name="defaults">
>           <int name="hl.fragsize">100</int>
>         </lst>
>       </fragmenter>
>       <formatter name="html" default="true" 
> class="solr.highlight.HtmlFormatter">
>         <lst name="defaults">
>           <str name="hl.simple.pre"><![CDATA[<em>]]></str>
>           <str name="hl.simple.post"><![CDATA[</em>]]></str>
>         </lst>
>       </formatter>
>       <encoder name="html" class="solr.highlight.HtmlEncoder" />
>     </highlighting>
>   </searchComponent>
>
> From what I can see from the documentation my JSON should look a bit like 
> this:
>
> {
>   "add-searchcomponent":{
>     "name":"myHighlightingComponent",
>     "class":"solr.HighlightComponent",
>     ??
>   }
> }
>
> However I have no idea how to defines the 2 fragmenters or the encoder.  Any 
> help is appreciated.
>
> Thanks
> Alex
>

Reply via email to