-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crated utils function for creating elastic client
- Loading branch information
Showing
5 changed files
with
15 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "pangaea" | ||
version = "0.2.0" | ||
version = "0.2.1" | ||
edition = "2021" | ||
authors = ["Niklas Frondorf <[email protected]>"] | ||
readme = "README.md" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ pub mod download_data; | |
mod error; | ||
pub mod metadata; | ||
mod prelude; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use elasticsearch::{http::transport::Transport, Elasticsearch}; | ||
use crate::prelude::*; | ||
|
||
pub fn get_elastic_client() -> Result<Elasticsearch> { | ||
let transport = Transport::single_node("https://ws.pangaea.de/es/pangaea")?; | ||
Ok(Elasticsearch::new(transport)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
use elasticsearch::{http::transport::Transport, Elasticsearch}; | ||
use pangaea::dataset::datasettype::Dataset; | ||
|
||
fn get_client() -> Elasticsearch { | ||
let transport = Transport::single_node("https://ws.pangaea.de/es/pangaea").unwrap(); | ||
Elasticsearch::new(transport) | ||
} | ||
use pangaea::{dataset::datasettype::Dataset, utils::get_elastic_client}; | ||
|
||
#[tokio::test] | ||
async fn dataset_new() { | ||
let dataset_id = 82037; | ||
|
||
let _ = Dataset::new(dataset_id, &get_client()).await.unwrap(); | ||
let _ = Dataset::new(dataset_id, &get_elastic_client().unwrap()).await.unwrap(); | ||
} | ||
|
||
#[tokio::test] | ||
async fn dataset_search() { | ||
let _ = Dataset::search(0, 10, None, &["sp-lastModified:desc"], &get_client()) | ||
let _ = Dataset::search(0, 10, None, &["sp-lastModified:desc"], &get_elastic_client().unwrap()) | ||
.await | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
use elasticsearch::{http::transport::Transport, Elasticsearch}; | ||
use pangaea::metadata::metadatatype::MetaDataType; | ||
|
||
fn get_client() -> Elasticsearch { | ||
let transport = Transport::single_node("https://ws.pangaea.de/es/pangaea").unwrap(); | ||
Elasticsearch::new(transport) | ||
} | ||
use pangaea::{metadata::metadatatype::MetaDataType, utils::get_elastic_client}; | ||
|
||
#[tokio::test] | ||
async fn metadata_new() { | ||
let dataset_id = 82037; | ||
|
||
let _ = MetaDataType::new(dataset_id, &get_client()).await.unwrap(); | ||
let _ = MetaDataType::new(dataset_id, &get_elastic_client().unwrap()).await.unwrap(); | ||
} | ||
|
||
#[tokio::test] | ||
async fn metadata_search() { | ||
let _ = MetaDataType::search(0, 10, None, &["sp-lastModified:desc"], &get_client()) | ||
let _ = MetaDataType::search(0, 10, None, &["sp-lastModified:desc"], &get_elastic_client().unwrap()) | ||
.await | ||
.unwrap(); | ||
} |