Skip to content

v1.10.1

Choose a tag to compare

@search5 search5 released this 27 Mar 06:51
· 23 commits to master since this release

solrpy 1.10.1 — Structured Query Builders

New: Field, Sort, Facet builder objects

Optional structured alternatives to raw string parameters. Fully backward compatible — raw strings always work.

Field builder

from solr import Field

conn.select('*:*', fields=[
    Field('id'),
    Field('price', alias='price_usd'),   # → price_usd:price
    Field.func('sum', 'price', 'tax'),    # → sum(price,tax)
    Field.transformer('explain'),          # → [explain]
    Field.score(),                         # → score
])

Sort builder

from solr import Sort

conn.select('*:*', sort=[
    Sort('price', 'desc'),
    Sort.func('geodist()', 'asc'),
])

Facet builder

from solr import Facet

conn.select('*:*', facets=[
    Facet.field('category', mincount=1, limit=10),
    Facet.range('price', start=0, end=100, gap=10),
    Facet.query('cheap', 'price:[0 TO 50]'),
    Facet.pivot('category', 'author'),
])

Raw strings still work

# This is equivalent and will always be supported
conn.select('*:*', fl='id,price', sort='price desc',
            facet='true', facet_field='category')

Verification

  • 351 tests passing (25 new builder tests)
  • mypy --strict → 0 errors (18 source files)
  • 0 docstring regressions

Full Changelog: v1.10.0...v1.10.1