ZivHus
ZivHus

Reputation: 67

How to design solr searchhandler in core mode and how to use it?

I'm using Solr 6.1.0 and not use cloud mode,

I has add searchhandler in solrconfig.xml and it's work, can see the search results

But when I use this searchhandler and add query in URL it'll error

Like this :

http://localhost:8983/solr/testcorea/contentsearch?indent=on&q=%22test%22&wt=json&shards=localhost:8983/solr/testcorea,localhost:8983/solr/testcoreb,localhost:8983/solr/testcorec,localhost:8983/solr/testcored

This is my searchhandler:

<requestHandler name="/contentsearch" class="solr.SearchHandler">
    <lst name="defaults">
        <str name="echoParams">explicit</str>
        <str name="wt">json</str>
        <str name="indent">true</str>

        <str name="defType">edismax</str>
        <str name="qf">
        title^100.0 content^80.0 text^5.0
        </str>
        <str name="q">*:*</str>
        <str name="indent">true</str>
        <str name="rows">10</str>

        <!-- Facet settings -->
        <str name="facet">on</str>
        <str name="facet.field">content_type</str>
        <str name="facet.field">category</str>
        <str name="facet.field">author</str>
        <str name="facet.field">editor</str>
        <str name="facet.field">source_type</str>

        <str name="hl">on</str>
        <str name="hl.fl">title content</str>
        <str name="hl.preserveMulti">true</str>
    </lst>    
    <arr name="last-components">
        <str>elevator</str>
    </arr>
</requestHandler>

Error message :

=========================================================================

{"responseHeader":{"status":404,"QTime":10,"params":{"q":"\"test\"","shards":"localhost:8983/solr/testcorea,localhost:8983/solr/testcoreb,localhost:8983/solr/testcorec,localhost:8983/solr/testcored","indent":"on","wt":"json"}},"error":{"metadata":["error-class","org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException","root-error-class","org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException"],"msg":"Error from server at http://localhost:8983/solr/testcorec: Expected mime type application/octet-stream but got text/html. \n\n\nError 404 Not Found\n\n

HTTP ERROR 404

\n

Problem accessing /solr/testcorec/contentsearch. Reason:\n

    Not Found

\n\n\n","code":404}}

When I use solr default searchhandlr and query url it'll work Like this :

http://localhost:8983/solr/testcorea/browse?indent=on&q=%22test%22&wt=json&shards=localhost:8983/solr/testcorea,localhost:8983/solr/testcoreb,localhost:8983/solr/testcorec,localhost:8983/solr/testcored

does anyone know what's different?

and why it does not work?

Thanks

Upvotes: 0

Views: 458

Answers (1)

Vinod
Vinod

Reputation: 1953

Add highlighting parameters to URL.

Add hl=on and hl.fl=field_name to your url

ex:

hl.fl=title&hl=on&indent=on&q=test

Upvotes: 1

Related Questions