Commit 72c949b4 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Sort persons by functions count.

parent 5e418342
......@@ -50,7 +50,7 @@ fn run_index(data_dir: &Path) -> tantivy::Result<()> {
let main_name_field = schema.get_field("main_name").unwrap();
let name_autocomplete_field = schema.get_field("name_autocomplete").unwrap();
let name_field = schema.get_field("name").unwrap();
// let securities_count_field = schema.get_field("securities_count").unwrap();
let functions_count_field = schema.get_field("functions_count").unwrap();
for entry in fs::read_dir(persons_dir).unwrap() {
let json_file_path = entry.unwrap().path();
......@@ -67,7 +67,7 @@ fn run_index(data_dir: &Path) -> tantivy::Result<()> {
person_doc.add_text(name_autocomplete_field, &name.to_string());
person_doc.add_text(name_field, &name.to_string());
}
// person_doc.add_u64(securities_count_field, person["securities"].len() as u64);
person_doc.add_u64(functions_count_field, person["functions"].len() as u64);
index_writer.add_document(person_doc);
}
index_writer.commit()?;
......
......@@ -189,8 +189,7 @@ impl_web!{
let searcher = self.index.searcher();
let mut count_collector = CountCollector::default();
let hits: Vec<Hit> = if q.is_empty() {
// let mut top_collector = TopFieldCollector::<u64>::with_limit(self.schema.get_field("securities_count").unwrap(), query_string.offset + query_string.limit);
let mut top_collector = TopScoreCollector::with_limit(query_string.offset + query_string.limit);
let mut top_collector = TopFieldCollector::<u64>::with_limit(self.schema.get_field("functions_count").unwrap(), query_string.offset + query_string.limit);
{
let mut chained_collector = collector::chain()
.push(&mut top_collector)
......
......@@ -34,7 +34,7 @@ pub fn build_index(data_dir: &Path) -> tantivy::Result<tantivy::Index> {
schema_builder.add_text_field("name_autocomplete", text_options);
}
schema_builder.add_u64_field("securities_count", FAST);
schema_builder.add_u64_field("functions_count", FAST);
let schema = schema_builder.build();
let index = Index::create_in_dir(&index_dir, schema.clone()).unwrap();
......@@ -59,8 +59,7 @@ fn register_tokenizers(index: &tantivy::Index) -> tantivy::Result<()> {
french_autocomplete_tokenizer,
);
let french_tokenizer = SimpleTokenizer
.filter(Slugifier);
let french_tokenizer = SimpleTokenizer.filter(Slugifier);
tokenizers.register("french_tokenizer", french_tokenizer);
Ok(())
......
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