Hi,
Thanks for info, however I got an error when adding the field using curl (sorry
for the long lines):
Command I used:
curl -k -u user:password https://solr:8443/solr/q/config -H
'Content-type:application/json' -d '{ "add-searchcomponent": { "highlight": {
"name": "myHighlight", "class": "srl'.HighlightComponent", "": { "gap": {
"default": "true", "name": "gap", "class": "solr.highlight.GapFragmente,"'
"defaults": { "hl.fragsize": 100 } } }, "html": [{ "default": "true", "name":
"html", "class": "solr.highlith'.HtmlFormatter", "defaults": { "hl.simple.pre":
"before-", "hl.simple.post": "-after" }}, { "name": "html", "class":
"solr.highlight.HtmlEncoder"}] }}}'
The error I got was :
'name' is a required field", "'class' is a required field"
I was able to figure out the correct format:
curl -k -u user:password https://solr:8443/solr/q/config -H
'Content-type:application/json' -d '{ "add-searchcomponent": { "name":
"highlight", "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":
before-", "hl.simple.post": "-after" }}, { "name": "html", "class":
"solr.highlight.HtmlEncoder"}] }}'
It was accepted by Solr and I can see it when going to the url
"solr//config". As you can see I use the 'highlight' name to
override the default one however my highlighter is not picked up by my request
handler. If I remove my highlight search component from the API and add it to
solrconfig.xml it is picked up by my request handler.
I compared the output of the url "solr//config" (solrconfig.xml
version) and it was identical to what I had before when I added the search
component using the API. I am at a loss why the search component works when
using solrconfig.xml but doesn't when using the Config API. Do you know why
this is the case?
I am using Solr 6.0.1 with ZooKeeper.
Thanks for any help
Alexandre Drouin
-Original Message-
From: Cassandra Targett [mailto:casstarg...@gmail.com]
Sent: July 8, 2016 5:04 PM
To: solr-user@lucene.apache.org
Subject: Re: How to create highlight search component using Config API
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":"",
"hl.simple.post":""}},{"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
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:
>
>name="myHighlightingComponent">
>
>class="solr.highlight.GapFragmenter">
>
> 100
>
>
>class="solr.highlight.HtmlFormatter">
>
>
>
>
>
>
>
>
>
> 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
>