Params
BreakIteratorType
How to segment text into passages for highlighting.
Controls where snippets begin and end: - SENTENCE: Break on sentence boundaries (recommended for natural-looking snippets) - WORD: Break on word boundaries - SEPARATOR: Break on a custom character - CHARACTER: Break anywhere - LINE: Break on line breaks - WHOLE: Treat entire field as one passage
Reference: https://solr.apache.org/guide/solr/latest/query-guide/highlighting.html
CommonParamsMixin
Bases: ParamsMixin
Common query parameters: https://solr.apache.org/guide/solr/latest/query-guide/common-query-parameters.html
FacetMethod
Faceting algorithm methods.
Choose based on your field characteristics: - ENUM: Best for fields with few distinct values (enumerates all terms) - FIELD_CACHE: Best for fields with many unique terms but few per document - PER_SEGMENT: Best for single-valued strings with frequent index updates
Reference: https://solr.apache.org/guide/solr/latest/query-guide/faceting.html#the-facet-method-parameter
FacetParamsConfig
Bases: ParamsConfig
Solr Faceting Configuration - Categorize and Count Search Results.
Faceting breaks down search results into categories with counts, enabling drill-down navigation and data analysis.
Official Documentation
https://solr.apache.org/guide/solr/latest/query-guide/faceting.html
Common Patterns:
Basic Field Faceting:
```python
config = FacetParamsConfig(
fields=['category', 'brand'], # Fields to facet on
limit=10, # Top 10 values
mincount=1 # Skip empty facets
)
```
Range Faceting (Prices, Dates):
```python
config = FacetParamsConfig(
range_field=['price'],
range_start={'price': '0'},
range_end={'price': '1000'},
range_gap={'price': '100'} # $0-100, $100-200, etc.
)
```
Filtered Facets:
```python
config = FacetParamsConfig(
fields=['color'],
prefix='bl', # Only colors starting with 'bl' (blue, black)
mincount=5 # Only show if 5+ matches
)
```
Performance Tips
- Use appropriate 'method' for your field type
- Set 'mincount' to reduce result size
- Consider 'threads' for parallel faceting on large datasets
FacetSort
GroupParamsConfig
Bases: ParamsConfig
Solr Result Grouping - Collapse Results by Common Values.
Result grouping (also known as field collapsing) combines documents that share a common field value. Useful for: - Showing one result per author, category, or domain - Preventing duplicate-like results from dominating - Creating grouped summaries of search results
Official Documentation
https://solr.apache.org/guide/solr/latest/query-guide/result-grouping.html
Example - Group by Price Range
config = GroupParamsConfig(
query=['price:[0 TO 50]', 'price:[50 TO 100]'], # Custom groups
limit=5 # Up to 5 docs per price range
)
Important Notes
- Grouped fields must be single-valued and indexed
- group.func doesn't work in distributed (SolrCloud) searches
- Use 'format="simple"' for flat response structure
- 'ngroups' and 'facet' require documents co-located on same shard
HighlightParamsConfig
Bases: ParamsConfig
Configuration for Solr Highlighting.
Highlighting allows you to show snippets of text from documents with query terms emphasized (usually wrapped in tags). Common use cases include: - Search result snippets showing matched terms in context - Preview text with keywords highlighted - Showing relevant passages from long documents
Official Documentation
https://solr.apache.org/guide/solr/latest/query-guide/highlighting.html
Example
# Basic highlighting setup
highlight_config = HighlightParamsConfig(
method='unified', # Use the recommended Unified Highlighter
fields=['title', 'content'], # Fields to highlight
snippets_per_field=3, # Show up to 3 snippets per field
fragment_size=150, # ~150 character snippets
tag_before='<mark>', # HTML tag before matched term
tag_after='</mark>' # HTML tag after matched term
)
Note
- Choose highlighter method based on your needs:
- 'unified': Most accurate, recommended (default)
- 'original': Works with any field configuration
- 'fastVector': Fast for large documents (requires termVectors=true)
MoreLikeThisParamsConfig
Bases: ParamsConfig
Solr MoreLikeThis (MLT) - Find Similar Documents.
MoreLikeThis finds documents similar to a given document by analyzing the terms that make it unique. Common use cases: - "Related articles" features - Product recommendations - Content discovery - Duplicate detection
Official Documentation
https://solr.apache.org/guide/solr/latest/query-guide/morelikethis.html
Basic Example
config = MoreLikeThisParamsConfig(
fields=['title', 'content'], # Analyze these fields
min_term_freq=2, # Term must appear 2+ times
min_doc_freq=5, # Term must be in 5+ documents
max_query_terms=25 # Use top 25 most interesting terms
)
Advanced Example
config = MoreLikeThisParamsConfig(
fields=['content'],
min_term_freq=1,
min_doc_freq=3,
min_word_len=4, # Ignore words shorter than 4 chars
max_doc_freq_pct=80, # Ignore terms in 80%+ of docs
interesting_terms='details' # Show which terms were used
)
Performance Tips
- Use fields with term vectors for best performance
- Adjust min_term_freq and min_doc_freq to filter noise
- Set max_num_tokens_parsed to limit analysis on large documents
SpatialSearchParamsMixin
Bases: ParamsMixin
Base mixin for spatial search parameters used by geofilt and bbox parsers.
spatial_params()
Build the spatial search parameters string for use in filter queries.