Commit ef379741 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Return all issuers when no search term is given.

parent 304c1586
......@@ -6,7 +6,7 @@ use std::path::Path;
use tantivy::collector;
use tantivy::collector::CountCollector;
use tantivy::collector::TopCollector;
use tantivy::query::QueryParser;
use tantivy::query::{AllQuery, QueryParser};
use tantivy::schema::NamedFieldDocument;
use tantivy::schema::Schema;
use tantivy::DocAddress;
......@@ -68,9 +68,14 @@ impl_web!{
#[get("/issuers")]
#[content_type("application/json")]
fn list(&self, query_string: SearchQuery) -> Result<ListResponse, ()> {
let query = self .list_query_parser
.parse_query(&query_string.q)
.expect("Parsing the query failed");
let q = query_string.q.trim();
let query = if q.is_empty() {
Box::new(AllQuery)
} else {
self .list_query_parser
.parse_query(q)
.expect("Parsing the query failed")
};
let searcher = self.index.searcher();
let mut count_collector = CountCollector::default();
......@@ -101,10 +106,14 @@ impl_web!{
#[get("/issuers/autocomplete")]
#[content_type("application/json")]
fn autocomplete(&self, query_string: SearchQuery) -> Result<AutocompleteResponse, ()> {
let query = self .autocomplete_query_parser
.parse_query(&query_string.q)
.expect("Parsing the query failed");
let q = query_string.q.trim();
let query = if q.is_empty() {
Box::new(AllQuery)
} else {
self .autocomplete_query_parser
.parse_query(q)
.expect("Parsing the query failed")
};
let searcher = self.index.searcher();
let mut count_collector = CountCollector::default();
let mut top_collector = TopCollector::with_limit(query_string.count);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment