A Solr client for Rust.
Rsolr
provides capabilities to manipulate and form
requests to the Solr server, and contains some shorthands
for them. It uses the blocking version of the reqwest http client.
## Query
You can retrieve documents as types with implemented Clone
and Deserialize
.
```rust use serdejson::Value; use rsolr::Client; use rsolr::error::RSolrError; use rsolr::solrresult::SolrResult;
fn queryall() -> Result
## Create
You can use types with implemented Clone
and Serialize
.
```rust
use serde::Serialize; use serde_json::Value; use rsolr::Client;
#[derive(Serialize, Clone)]
struct SimpleDocument {
field: Vec
fn create() {
let document = SimpleDocument { field: vec!("nice".tostring(), "document".tostring()) };
Client::new("http://solr:8983", "collection")
.create(document)
.run::
rust
use serde_json::Value;
use rsolr::Client;
fn delete() {
Client::new("http://solr:8983", "collection")
.delete("delete:query")
.run::<Value>().expect("panic, request failed.");
}
## Custom handler with params
You can define any handlers as well.
```rust
use serdejson::Value;
use rsolr::Client;
use rsolr::error::RSolrError;
use rsolr::solrresult::SolrResult;
fn morelikethis() -> Result
I use Cargo Run Script to setup and manage a Solr locally. You'll also need a Docker. After checkout you should run
cargo run-script solr-start
cargo run-script solr-provision
Now you can reach your local Solr on http://localhost:8983
. For testing I created a default collection without any schema def. Practically it means every value will be multivalue by default.