Erik
Erik

Reputation: 274

How do I set a default field list in my solr schema?

I have a schema that contains a fairly large text field.

I've gzipped it and enabled lazy loading, but it will still be fetched unless every client using solr explicitly sets the field list (fl) parameter.

How can I configure solr to omit the large gzipped text field from the results when querying without a field list parameter?

Upvotes: 1

Views: 3133

Answers (1)

Paige Cook
Paige Cook

Reputation: 22555

The simplest way to do this is to add the field list to the requestHandler. Assuming that you are using the default /select request handler, you will need to modify your solrconfig.xml adding the fl option to the list of defaults for the /select requestHandler. See below for an example.

 <requestHandler name="/select" class="solr.SearchHandler">
   <!-- default values for query parameters can be specified, these
           will be overridden by parameters in the request
    -->
   <lst name="defaults">
     <str name="echoParams">explicit</str>
     <int name="rows">10</int>
     <str name="fl">field1,field2,field3</str>
   </lst>

  ....

 </requestHandler>

So in this example, I am setting the fl parameter so the query will return field1, field2 and field3 by default. These will be the fields returned when querying unless the request specifies the fl parameter and then whatever fields are sent will be returned.

These defaults can be set per requestHandler, so if you are using an different requestHandler, then just modify your configuration as needed.

Hope this helps.

Upvotes: 3

Related Questions