Browse Source

Aligned tantivy-cli with tantivy 0.5

develop
Paul Masurel 6 years ago
parent
commit
a74c3afe89
2 changed files with 3 additions and 3 deletions
  1. +2
    -1
      src/commands/new.rs
  2. +1
    -2
      src/commands/search.rs

+ 2
- 1
src/commands/new.rs View File

@@ -2,6 +2,7 @@ use clap::ArgMatches;
use std::convert::From;
use std::path::PathBuf;
use tantivy;
use tantivy::schema::Cardinality;
use tantivy::schema::*;
use tantivy::Index;
use std::io;
@@ -111,7 +112,7 @@ fn ask_add_field_u64(field_name: &str, schema_builder: &mut SchemaBuilder) {
u64_options = u64_options.set_stored();
}
if prompt_yn("Should the field be fast") {
u64_options = u64_options.set_fast();
u64_options = u64_options.set_fast(Cardinality::SingleValue);
}
if prompt_yn("Should the field be indexed") {
u64_options = u64_options.set_indexed();


+ 1
- 2
src/commands/search.rs View File

@@ -8,7 +8,6 @@ use tantivy::query::QueryParser;
use tantivy::schema::Field;
use serde_json;
use tantivy::schema::FieldType;
use tantivy::tokenizer::*;

pub fn run_search_cli(matches: &ArgMatches) -> Result<(), String> {
let index_directory = PathBuf::from(matches.value_of("index").unwrap());
@@ -39,7 +38,7 @@ fn run_search(directory: &Path, query: &str) -> tantivy::Result<()> {
let query_parser = QueryParser::new(schema.clone(), default_fields, index.tokenizers().clone());
let query = query_parser.parse_query(query)?;
let searcher = index.searcher();
let weight = query.weight(&searcher)?;
let weight = query.weight(&searcher, false)?;
let schema = index.schema();
for segment_reader in searcher.segment_readers() {
let mut scorer = weight.scorer(segment_reader)?;


Loading…
Cancel
Save