Expand description
Solrstice is a Solr 8+ client for Rust. Take a look at AsyncSolrCloudClient and SelectQuery for more documentation
§Examples
use serde::{Deserialize, Serialize};
use solrstice::AsyncSolrCloudClient;
use solrstice::SolrSingleServerHost;
use solrstice::SolrBasicAuth;
use solrstice::{SolrServerContextBuilder};
use solrstice::Error;
use solrstice::{DeleteQuery, UpdateQuery};
use solrstice::SelectQuery;
use std::path::Path;
#[derive(Serialize, Deserialize, Debug)]
struct TestData {
id: String,
}
#[tokio::test]
pub async fn example() -> Result<(), Error> {
//Create a solr client. You can also use a list of zookeeper hosts instead of a single server.
let context = SolrServerContextBuilder::new(SolrSingleServerHost::new("http://localhost:8983"))
.with_auth(SolrBasicAuth::new("solr", Some("SolrRocks"))).build();
let client = AsyncSolrCloudClient::new(context);
// Upload config
client
.upload_config("example_config", Path::new("/path/to/config"))
.await?;
// Create collection
client
.create_collection("example_collection", "example_config", 1, 1)
.await?;
// Index document
let docs = vec![TestData {
id: "example_document".to_string(),
}];
client
.index(
&UpdateQuery::new(),
"example_collection",
docs.as_slice(),
)
.await?;
// Search and retrieve the document
let docs = client
.select(
&SelectQuery::new().fq(["id:example_document"]),
"example_collection",
)
.await?
.get_docs_response()
.ok_or("No response provided")?
.get_docs::<TestData>()?;
// Delete the document
client
.delete(
&DeleteQuery::new().ids(["example_document"]),
"example_collection",
)
.await?;
Ok(())
}
Modules§
- models
- Model structs Models used by the Solr Client.
- queries
- Query types The different query types this library supports.
Structs§
- Async
Solr Cloud Client - Async client for SolrCloud
- Delete
Query - A builder for deleting documents.
- Dismax
Query - The dismax query parser
- Edismax
Query - The extended dismax query parser
- Facet
SetComponent - Get facet counts for different types of faceting.
- Field
Facet Component - Component for field facets
- Field
Facet Entry - A field facet entry represents a single field facet.
- Grouping
Component - Group documents by a field or query.
- Json
Facet Component - Get self defined facets.
- Json
Query Facet - A facet that does a query and returns the number of documents that match
- Json
Stat Facet - A facet that does a query and gets the number of results
- Json
Terms Facet - A facet that counts the number of documents that match a query
- Logging
Watcher - Lucene
Query - The default query parser
- Pivot
Facet Component - A facet component for pivot facets.
- Select
Query - Builder for a select query.
- Solr
Basic Auth - Basic Authentication
- Solr
Multiple Server Host - Connect to multiple solr hosts. Acts as a load balancer with random selection
- Solr
Request Builder - Solr
Server Context - A SolrServerContext specifies how to connect to a solr server, and how to authenticate.
- Solr
Server Context Builder - A SolrServerContext specifies how to connect to a solr server, and how to authenticate.
- Solr
Single Server Host - Connect to a single solr host Good for if you have an external load balancer
- Update
Query - A builder for the update handler.
- Zookeeper
Ensemble Host - Connect to zookeeper instances to get a list of solr nodes to connect to. Select randomly from the list of live nodes. The timeout is used to determine how long to wait for a response from a solr host before trying the next one
- Zookeeper
Ensemble Host Connector - Connect to zookeeper instances to get a list of solr nodes to connect to. Select randomly from the list of live nodes. The timeout is used to determine how long to wait for a response from a solr host before trying the next one
Enums§
- Commit
Type - This struct encapsulates the commit types for Solr’s update and delete queries.
By default, a
Hard
commit is performed, equating tocommit=true
. Conversely, aSoft
commit corresponds tosoftCommit=true
. - DefType
- Error
- Main error type for Solrstice
- Field
Facet Method - Set the method to do the facet calculation. Default is Fc.
- Field
Facet Sort - Set the sorting order of field facets
- Group
Formatting - How to format groups. The default is GroupFormatting::Grouped.
- Json
Facet Type - The different types of facets supported by JsonFacet
- Logging
Policy - How detailed the logs of the requests should be
For
Fast
andPretty
the number is the maximum length of the body that will be logged Logging will be with thedebug
level - Query
Operator