solrstice/
lib.rs

1//! Solrstice is a Solr 8+ client for Rust.
2//! Take a look at [AsyncSolrCloudClient](crate::clients::async_cloud_client::AsyncSolrCloudClient) and [SelectQuery](crate::queries::select::SelectQuery) for more documentation
3//! # Examples
4//! ```no_run
5//! use serde::{Deserialize, Serialize};
6//! use solrstice::AsyncSolrCloudClient;
7//! use solrstice::SolrSingleServerHost;
8//! use solrstice::SolrBasicAuth;
9//! use solrstice::{SolrServerContextBuilder};
10//! use solrstice::Error;
11//! use solrstice::{DeleteQuery, UpdateQuery};
12//! use solrstice::SelectQuery;
13//! use std::path::Path;
14//!
15//! #[derive(Serialize, Deserialize, Debug)]
16//! struct TestData {
17//!     id: String,
18//! }
19//!
20//! #[tokio::test]
21//! pub async fn example() -> Result<(), Error> {
22//!
23//!     //Create a solr client. You can also use a list of zookeeper hosts instead of a single server.
24//!     let context = SolrServerContextBuilder::new(SolrSingleServerHost::new("http://localhost:8983"))
25//!         .with_auth(SolrBasicAuth::new("solr", Some("SolrRocks"))).build();
26//!     let client = AsyncSolrCloudClient::new(context);
27//!
28//!     // Upload config
29//!     client
30//!         .upload_config("example_config", Path::new("/path/to/config"))
31//!         .await?;
32//!
33//!     // Create collection
34//!     client
35//!         .create_collection("example_collection", "example_config", 1, 1)
36//!         .await?;
37//!
38//!     // Index document
39//!     let docs = vec![TestData {
40//!         id: "example_document".to_string(),
41//!     }];
42//!     client
43//!         .index(
44//!             &UpdateQuery::new(),
45//!             "example_collection",
46//!             docs.as_slice(),
47//!         )
48//!         .await?;
49//!
50//!     // Search and retrieve the document
51//!     let docs = client
52//!         .select(
53//!             &SelectQuery::new().fq(["id:example_document"]),
54//!             "example_collection",
55//!         )
56//!         .await?
57//!         .get_docs_response()
58//!         .ok_or("No response provided")?
59//!         .get_docs::<TestData>()?;
60//!
61//!     // Delete the document
62//!     client
63//!         .delete(
64//!             &DeleteQuery::new().ids(["example_document"]),
65//!             "example_collection",
66//!         )
67//!         .await?;
68//!     Ok(())
69//! }
70//! ```
71
72/// Solr Clients
73mod clients;
74pub use clients::async_cloud_client::*;
75#[cfg(feature = "blocking")]
76pub use clients::blocking_cloud_client::*;
77
78/// Host types
79mod hosts;
80pub use crate::hosts::solr_host::*;
81pub use crate::hosts::solr_server_host::*;
82pub use crate::hosts::zookeeper_host::*;
83/// Model structs
84pub mod models;
85pub use models::auth::*;
86pub use models::commit_type::*;
87pub use models::context::*;
88/// Query types
89pub mod queries;
90pub use queries::components::facet_set::*;
91pub use queries::components::grouping::*;
92pub use queries::components::json_facet::*;
93pub use queries::components::stats::*;
94pub use queries::def_type::*;
95pub use queries::index::*;
96pub use queries::request_builder::*;
97pub use queries::select::*;
98#[cfg(feature = "blocking")]
99/// Tokio Runtime for blocking usage
100mod runtime;
101
102#[cfg(doctest)]
103pub mod docs;
104/// Error types for the library.
105pub(crate) mod error;
106pub use error::Error;