Skip to main content

A Solr client library written in Rust

Project description

Solrstice: A Solr 8+ Client for Rust and Python

Solrstice is a solr client library written in rust. With this wrapper you can use it in python.

Both asyncio and blocking clients are provided. All apis have type hints. Documentation can be found at sh1nku.github.io/solrstice/python

Features

  • Config API
  • Collection API
  • Alias API
  • Select Documents
    • Grouping Component Query
    • DefTypes (lucene, dismax, edismax)
  • Indexing Documents
  • Deleting Documents

Installation

pip install solrstice

Basic Usage

Async

import asyncio
from solrstice.clients import AsyncSolrCloudClient
from solrstice.hosts import SolrSingleServerHost, SolrServerContext
from solrstice.auth import SolrBasicAuth
from solrstice.queries import UpdateQueryBuilder, SelectQueryBuilder, DeleteQueryBuilder

# A SolrServerContext specifies how the library should interact with Solr
context = SolrServerContext(SolrSingleServerHost('localhost:8983'), SolrBasicAuth('solr', 'SolrRocks'))
client = AsyncSolrCloudClient(context)

async def main():
    # Create config and collection
    await client.upload_config('example_config', 'path/to/config')
    await client.create_collection('example_collection', 'example_config', shards=1, replication_factor=1)
    
    # Index a document
    await client.index(UpdateQueryBuilder(), 'example_collection', [{'id': 'example_document', 'title': 'Example document'}])
    
    # Search for the document
    response = await client.select(SelectQueryBuilder(fq=['title:Example document']), 'example_collection')
    docs = response.get_response().docs
    
    # Delete the document
    await client.delete(DeleteQueryBuilder(ids=['example_document']), 'example_collection')
    

asyncio.run(main())

Blocking

from solrstice.clients import BlockingSolrCloudClient
from solrstice.hosts import SolrSingleServerHost, SolrServerContext
from solrstice.auth import SolrBasicAuth
from solrstice.queries import UpdateQueryBuilder, SelectQueryBuilder, DeleteQueryBuilder

# A SolrServerContext specifies how the library should interact with Solr
context = SolrServerContext(SolrSingleServerHost('localhost:8983'), SolrBasicAuth('solr', 'SolrRocks'))
client = BlockingSolrCloudClient(context)

# Create config and collection
client.upload_config('example_config', 'path/to/config')
client.create_collection('example_collection', 'example_config', shards=1, replication_factor=1)

# Index a document
client.index(UpdateQueryBuilder(), 'example_collection', [{'id': 'example_document', 'title': 'Example document'}])

# Search for the document
response = client.select(SelectQueryBuilder(fq=['title:Example document']), 'example_collection')
docs = response.get_response().docs

# Delete the document
client.delete(DeleteQueryBuilder(ids=['example_document']), 'example_collection')

Notes

  • Multiprocessing does not work, and will block forever. Normal multithreading works fine.

Grouping component

Field grouping

group_builder = GroupingComponent(fields=["age"], limit=10)
select_builder = SelectQueryBuilder(fq=["age:[* TO *]"], grouping=group_builder)
groups = await client.select(select_builder, "example_collection").get_groups()
age_group = groups["age"]
docs = age_group.get_field_result()

Query grouping

group_builder = GroupingComponent(queries=["age:[0 TO 59]", "age:[60 TO *]"], limit=10)
select_builder = SelectQueryBuilder(fq=["age:[* TO *]"], grouping=group_builder)
groups = await client.select(select_builder, "example_collection").get_groups()
age_group = groups["age:[0 TO 59]"]
group = age_group.get_query_result()
docs = group.docs

Query parsers

Lucene

query_parser = LuceneQueryBuilder(df="population")
select_builder = SelectQueryBuilder(q="outdoors", def_type=query_parser)
await client.select(select_builder, "example_collection")
docs = response.get_response().docs

Dismax

query_parser = DismaxQueryBuilder(qf="interests^20", bq=["interests:cars^20"])
select_builder = SelectQueryBuilder(q="outdoors", def_type=query_parser)
await client.select(select_builder, "example_collection")
docs = response.get_response().docs

Edismax

query_parser = EdismaxQueryBuilder(qf="interests^20", bq=["interests:cars^20"])
select_builder = SelectQueryBuilder(q="outdoors", def_type=query_parser)
await client.select(select_builder, "example_collection")
docs = response.get_response().docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solrstice-0.2.0.tar.gz (65.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

solrstice-0.2.0-cp38-abi3-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.8+Windows x86-64

solrstice-0.2.0-cp38-abi3-win32.whl (2.0 MB view details)

Uploaded CPython 3.8+Windows x86

solrstice-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

solrstice-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (5.5 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ s390x

solrstice-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (5.3 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ppc64le

solrstice-0.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (5.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ i686

solrstice-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (4.7 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARMv7l

solrstice-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

solrstice-0.2.0-cp38-abi3-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

solrstice-0.2.0-cp38-abi3-macosx_10_7_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.8+macOS 10.7+ x86-64

File details

Details for the file solrstice-0.2.0.tar.gz.

File metadata

  • Download URL: solrstice-0.2.0.tar.gz
  • Upload date:
  • Size: 65.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.2.0

File hashes

Hashes for solrstice-0.2.0.tar.gz
Algorithm Hash digest
SHA256 85fb43e8dfdd553498275c6d86aa98dcd64b556f2a1560069ab85c2e378d830e
MD5 cd8a4327b5ee53aa5c88edf0037a2087
BLAKE2b-256 54da1b868fe37e8b3f5fa0bad6243d70099ecec645bc146fbd0c4678c9271236

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: solrstice-0.2.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.2.0

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e603d5f13c196b07e5726d711e53ada399592da6cc4d87fed8468dbd53590ddd
MD5 4568372c9fa0f0380ce25353d739aa1f
BLAKE2b-256 481ca200fb94c89153ce1f49b171935b035d8547b87cdf433401e7c71e506709

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-win32.whl.

File metadata

  • Download URL: solrstice-0.2.0-cp38-abi3-win32.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.2.0

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 c80b14282b74638670cea42d47ee2da872f612338d6763b20e007f2a0783521f
MD5 2356e7b0d84d4742757a1e31af8455b5
BLAKE2b-256 db95fa8d84ccb6802135d1a44b8e15cfdbc84bcf8adda2132eb87c2d9573add4

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4aa2b2fbe2ed08624bce62b374e46f55d5dfca749bab5cae67cb105dd7fa0df9
MD5 9aee30673254b7863cfa86bb8ced23be
BLAKE2b-256 71c03ea874a26b252809aecb96a056b00eebf9da496f6d70a628c0c579a2bcba

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 9436873727a3b3ab4f0df6e20b664047dddddce325a0fcfd04fd35e1ed99d7b8
MD5 736a0ff83d53976ed000f0787091e4f1
BLAKE2b-256 45d117ce7b74e8f0b6138be2965cf86a9cce8cf0cac1ca68d871d314a602fe29

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 eb15571bdb896082b3906a14ab05cb8105a813ef7ad268edab7ab4cffb3d4e0e
MD5 2b64b13e695a9f83209bbd928cc23322
BLAKE2b-256 dc8db0dab67fc7be4141b8a048d7e157bc39ab40948e292d7d66fe19b41c2000

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 e3f75c05ff9c459a9417b8227915636e1622dc631aa2c5c50c4cf87762bc8e5b
MD5 ab0c41365065cea6d441a72380b9a079
BLAKE2b-256 cd2cf7c309c942bbf944c63de0b015f6fff0d55aa9d289656c694fe75b27986f

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 99091c54d7bbd82a40024e7ded768e24499771dd7976e176f203e696bb32fa23
MD5 1c2a6b76a2f66411df52254132cf35a7
BLAKE2b-256 47d5096f887f975f3b13599022bb6045d4491dd33b422af45d365969b6bcc354

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 37caa8534628c696f893413fc9d9ab65a64a06db57c38a30e492bf4be8b77eea
MD5 c58a4a50fae51278ba9da5d8af1a64d4
BLAKE2b-256 469f38643a3bff96a0ea87e6ce6a36a71c6034fe4736aaedca150939606b5c56

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5eb8d7e4de53bb1474aedd32105d7ecc7cdf828ec053b92fe887b8020b6eef62
MD5 0ca485143dcc67ff3d877f6a805424b0
BLAKE2b-256 20c7de7ebe86aad19040d0f0fc5e98e6ef0fb114fd9d08a64bc655127cd8c97f

See more details on using hashes here.

File details

Details for the file solrstice-0.2.0-cp38-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for solrstice-0.2.0-cp38-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5f8fb6a6b728e8383517d998c531226e96126012a0f802546afc8ccbb683eac9
MD5 cfce9663a3dd1307a21a89d9c4e7301c
BLAKE2b-256 279016e34ad551dfc10e7a3e81dcef62886e7aa5aaf43c44e8700e96ff736f12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page