Created
January 22, 2019 23:12
-
-
Save illicitonion/82f47be4f2a7eaa8bc513d17fa6a1f4b to your computer and use it in GitHub Desktop.
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
diff --git a/src/handlers/search.rs b/src/handlers/search.rs | |
index 9992c5b..9fbeae0 100644 | |
--- a/src/handlers/search.rs | |
+++ b/src/handlers/search.rs | |
@@ -36,14 +36,13 @@ impl_web! { | |
pub fn doc_search(&self, body: Request, index: String) -> impl Future<Item = SearchResults, Error = Error> + Send { | |
info!("Query: {:?}", body); | |
let mut futs = Vec::new(); | |
- let boxed_str = Box::leak(index.into_boxed_str()); | |
match self.catalog.read() { | |
Ok(cat) => { | |
- if cat.exists(boxed_str) { | |
- futs.push(future::Either::A(cat.search_local_index(boxed_str, body.clone()))); | |
+ if cat.exists(&index) { | |
+ futs.push(future::Either::A(cat.search_local_index(&index, body.clone()))); | |
} | |
- if cat.remote_exists(boxed_str) { | |
- futs.push(future::Either::B(cat.search_remote_index(boxed_str, body.clone()))); | |
+ if cat.remote_exists(&index) { | |
+ futs.push(future::Either::B(cat.search_remote_index(&index, body.clone()))); | |
} | |
return future::join_all(futs).map(|r| SearchHandler::fold_results(r)); | |
} | |
diff --git a/src/index.rs b/src/index.rs | |
index 0196c01..f3d754e 100644 | |
--- a/src/index.rs | |
+++ b/src/index.rs | |
@@ -192,12 +192,12 @@ impl IndexCatalog { | |
client_fut | |
} | |
- pub fn search_local_index(&self, index: &'static str, search: Request) -> impl Future<Item = SearchResults, Error = Error> + Send + 'static { | |
+ pub fn search_local_index(&self, index: &str, search: Request) -> impl Future<Item = SearchResults, Error = Error> + Send + 'static { | |
dbg!(&search); | |
self.get_index(index).and_then(move |hand| hand.search_index(search)).into_future() | |
} | |
- pub fn search_remote_index(&self, index: &'static str, search: Request) -> impl Future<Item = SearchResults, Error = Error> + Send { | |
+ pub fn search_remote_index(&self, index: &str, search: Request) -> impl Future<Item = SearchResults, Error = Error> + Send { | |
match self.get_remote_index(index) { | |
Ok(hand) => hand | |
.search_index(search) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment