Drupal’s Search API and Facet API often generate large, complex Solr queries like this:
?q={!boost b=boost_document} *:* &
fq=(+available:true +display_in_catalog:Yes +(*:* -facet_field:X)) &
facet.field=field_languages &
facet.field=field_formats &
facet.field=field_categories &
facet.limit=-1 &
facet.mincount=1 &
rows=20
From Solr’s debug section:
SimpleFacetsFCS (FieldCache Scanning)facet.limit=-1, facet.missing=falseSo, the query itself is fine — it’s the faceting that eats up most of the runtime.
*:* Query PatternDrupal often sends {!boost b=boost_document} *:*, meaning “match everything.”
Even with filters, Solr still evaluates the entire index before narrowing results.
That’s expensive, especially on big collections.
fq FiltersDozens of filters like:
fq=field_a:valueA fq=field_b:valueB fq=(+available:true +display_in_catalog:Yes)
Each one adds cost — especially negations like (*:* -field:value) or range queries like [ * TO * ].
Fields such as field_language, field_format, field_category, etc. are all requested, often with:
facet.limit = -1 facet.missing = false facet.sort = count
Each of these facets has to count every term across every matching document. That’s the main bottleneck — the facet block alone took ~1700ms.
Solr’s FCS method scans the entire field value space. When many documents or multi-valued fields are involved, it’s slow. The newer enum or stream methods, or JSON facets, are more efficient.
In Configuration → Search API → View Modes, disable facets that aren’t visible on the page.
Every active facet triggers Solr work, even if Drupal doesn’t render it.
In Facet API settings, set:
facet.limit = 50 facet.mincount = 1
Avoid facet.limit=-1 — that means “return everything.”
facet.missing=falseThis setting forces Solr to calculate missing values. Unless your UX needs it, remove it.
If your Solr core is 7.x or newer, switch Drupal’s Search API backend to use the JSON Facet API.
It’s faster, parallelized, and supports streaming facet counts.
Enable Drupal’s Search API query cache and facet cache.
It prevents Solr from recomputing identical facets for repeated queries.
Ensure your Solr solrconfig.xml includes:
<filterCache class="solr.FastLRUCache" size="512" initialSize="512" autowarmCount="128"/>
This helps repeated filters (like available:true) resolve instantly.
facet.threadsIf you must run many facets:
facet.threads=4
Parallelizes field facet computation.
Ensure all facet fields are stored with docValues="true" in the schema:
<field name="field_languages" type="string" stored="true" indexed="true" docValues="true"/>
This speeds up both faceting and sorting.
Switch from classic facet.field to:
json.facet={ categories: { type: "terms", field: "field_category", limit: 50 }, formats: { type: "terms", field: "field_format", limit: 50 } }
These APIs skip legacy overhead.
From your debug trace:
"facet-debug": { "elapse": 1704, "processor": "SimpleFacets", "appliedMethod": "FCS", "inputDocSetSize": 10 }
Even with only 10 returned documents, the facet engine must still traverse the full dataset to count terms. This is why even small result sets can be slow when facets are many or unbounded.
| Area | Action | Typical Gain |
|---|---|---|
| Drupal Facet Limit | Set facet.limit=50 |
60–80% faster |
Remove facet.missing |
Disable | 5–15% faster |
| Enable caching | Drupal + Solr | Big |
| Use DocValues | Schema config | Major |
| Use JSON facets | Modern Solr | 2–5× faster |
Avoid *:* base queries |
Use tighter filters | Major |
| facet.threads=4 | Solr config | 20–40% faster |
Before:
?q={!boost b=boost_document} *:*&facet.limit=-1&facet.field=...
After:
?q=*:*&fq=available:true&fq=display_in_catalog:Yes&
facet.limit=50&
facet.threads=4&
json.facet={
languages:{type:terms,field:field_language,limit:50},
formats:{type:terms,field:field_format,limit:50}
}
The slowdown isn’t Solr being “slow” — it’s Drupal asking for everything at once.
By trimming unnecessary facets, tightening query filters, and enabling JSON facets with DocValues, you can cut load time by 80–90% without losing functionality.
This tutorial applies to any Drupal + Apache Solr setup where complex facet-heavy queries are generated by the Search API or Facet API modules.