Mihai238
Mihai238

Reputation: 1137

Is it possible to have default filter values in Apache Solr?

Is it possible to tell Solr to use a specific filter value if no other filter is defined for that field?

Example: If there is no other fq entry present for a field age then search by default for age > 18.

Upvotes: 0

Views: 402

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

Yes, you can add these to the requestHandler definition:

<lst name="defaults">
  <str name="fq">age:[18 TO *]</str>
</lst>

(or if you really meant larger than 18 and not 18 or older, {18 TO *] or [19 TO *]).

You can also use appends and invariants instead of defaults to add a filter query to all queries or set a parameter to a static value that an URL parameter can't override.

Upvotes: 1

Related Questions