[][src]Trait stellr::prelude::SolrCoreMethods

pub trait SolrCoreMethods {
    pub fn live_node_url(&self) -> SolrResult<String>;
pub fn request_config(&self) -> &SolrClientConfig;
pub fn set_request_config(&mut self, request_config: SolrClientConfig); pub fn build_request_url(&self, path: &str) -> SolrResult<String> { ... }
pub fn build_client(&self) -> SolrResult<Client> { ... }
pub fn create_get_request(&self, path: &str) -> SolrResult<RequestBuilder> { ... }
pub fn create_post_request(&self, path: &str) -> SolrResult<RequestBuilder> { ... } }

Add a set of helper methods for "classic Solr" (non-cloud) targets.

The stellr crate separates out the node access (eg. via DirectSolrClient or ZkSolrClient structs) from the querying of the solr instances (via the SolrCoreMethods and SolrCloudMethods traits). This trait can be used with both Direct and Zookeeper-mediated clients.

Its main purpose is to create reqwest::RequestBuilder instances using the connection information from the underlying client, via the create_get_request and create_post_request methods.

// running solr locally using "solr start -e techproducts"
use stellr::prelude::*;
use stellr::response_types::SolrSelectType;
use serde_json;

let solr_client = stellr::DirectSolrClient::new("localhost:8983")?;
let solr_request = solr_client
    .create_get_request("/solr/techproducts/select")
    .expect("HTTP request creation failed...")
    .q(r#"*:*"#);

let solr_result =
    solr_request
    .unstructured_call()
    .await
    .expect("Failed to parse")
;

let num_found = solr_result
    .get("response").unwrap()
    .get("numFound").unwrap();

assert_eq!("32", num_found);

The one method which has to be implemented is live_node_url. All other methods have default implementations.

Required methods

pub fn live_node_url(&self) -> SolrResult<String>[src]

Extract a string-encoded base URL for the protocol and domainname of one host

pub fn request_config(&self) -> &SolrClientConfig[src]

Return a reference to a SolrClientConfig

pub fn set_request_config(&mut self, request_config: SolrClientConfig)[src]

Return a reference to a SolrClientConfig

Loading content...

Provided methods

pub fn build_request_url(&self, path: &str) -> SolrResult<String>[src]

Create a string-encoded URL using a supplied path and the result of live_node_url()

pub fn build_client(&self) -> SolrResult<Client>[src]

Generate a new reqwest::Client using SolrClientConfig supplied by the caller

pub fn create_get_request(&self, path: &str) -> SolrResult<RequestBuilder>[src]

Generate a GET request builder, based on the base_url from the client and a path from the caller

pub fn create_post_request(&self, path: &str) -> SolrResult<RequestBuilder>[src]

Generate a POST request builder, based on the base_url from the client and a path from the caller

Loading content...

Implementors

impl SolrCoreMethods for DirectSolrClient[src]

impl SolrCoreMethods for ZkSolrClient[src]

Loading content...