doc: Update the README for the new CLI

This commit is contained in:
Clément Renault 2018-10-04 13:55:29 +02:00
parent 474028145d
commit 2944368897
4 changed files with 15 additions and 13 deletions

View File

@ -22,7 +22,7 @@ git = "https://github.com/Kerollmops/fst.git"
branch = "automaton-for-deref" branch = "automaton-for-deref"
[features] [features]
default = ["index-csv", "serve-http", "serve-console"] default = ["index-csv", "serve-http"]
index-jsonlines = ["index", "serde_json"] index-jsonlines = ["index", "serde_json"]
index-csv = ["index", "csv"] index-csv = ["index", "csv"]

View File

@ -6,20 +6,22 @@ Raptor, the new RISE
First you need to generate the index files. First you need to generate the index files.
```bash ```bash
$ cargo build --release --bin raptor-indexer $ cargo build --release
$ time ./target/release/raptor-indexer products.json_lines $ time ./target/release/raptor-cli index csv --stop-words stop-words.txt the-csv-file.csv
``` ```
The `stop-words.txt` file here is a simple file that contains one stop word by line.
Once the command finished indexing you will have 3 files that compose the index: Once the command finished indexing you will have 3 files that compose the index:
- The `xxx.map` represent the fst map. - The `xxx.map` represent the fst map.
- The `xxx.idx` represent the doc indexes matching the words in the map. - The `xxx.idx` represent the doc indexes matching the words in the map.
- The `xxx.sst` is a file that contains all the fields and the values asociated with it, it is passed to the internal RocksDB. - The `xxx.sst` is a file that contains all the fields and the values asociated with it, it is passed to the internal RocksDB.
Now you can easily use `raptor-search` or `raptor-http` with only the prefix name of the files. (e.g. relaxed-colden). Now you can easily use `raptor server console` or `raptor serve http` with the name of the dump. (e.g. relaxed-colden).
```bash ```bash
$ cargo run --bin raptor-search -- relaxed-colden $ cargo build --release --default-features --features serve-console
$ cargo run --bin raptor-http -- relaxed-colden $ ./target/release/raptor-cli serve console --stop-words stop-words.txt relaxed-colden
``` ```
Note: If you have performance issues run the searcher in release mode (i.e. `--release`). Note: If you have performance issues run the searcher in release mode (i.e. `--release`).

View File

@ -10,7 +10,7 @@ use structopt::StructOpt;
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
#[structopt(name = "raptor-cli", about = "A command line to do raptor operations.")] #[structopt(name = "raptor-cli", about = "A command line to do raptor operations.")]
enum Commands { enum Command {
#[cfg(feature = "index")] #[cfg(feature = "index")]
/// Index files of different format. /// Index files of different format.
#[structopt(name = "index")] #[structopt(name = "index")]
@ -23,10 +23,10 @@ enum Commands {
} }
fn main() { fn main() {
let ret = match Commands::from_args() { let ret = match Command::from_args() {
#[cfg(feature = "index")] #[cfg(feature = "index")]
Commands::Index(i) => match i { Command::Index(i) => match i {
#[cfg(feature = "index-jsonlines")] #[cfg(feature = "index-jsonlines")]
index::CommandIndex::JsonLines(command) => index::jsonlines_feature::json_lines(command), index::CommandIndex::JsonLines(command) => index::jsonlines_feature::json_lines(command),
@ -36,7 +36,7 @@ fn main() {
}, },
#[cfg(feature = "serve")] #[cfg(feature = "serve")]
Commands::Serve(s) => match s { Command::Serve(s) => match s {
#[cfg(feature = "serve-http")] #[cfg(feature = "serve-http")]
serve::CommandServe::Http(command) => serve::http_feature::http(command), serve::CommandServe::Http(command) => serve::http_feature::http(command),

View File

@ -21,6 +21,9 @@ struct Document<'a> {
image: &'a str, image: &'a str,
} }
#[derive(Debug, Deserialize)]
struct SearchQuery { q: String }
pub struct HttpServer { pub struct HttpServer {
listen_addr: SocketAddr, listen_addr: SocketAddr,
common_words: Arc<CommonWords>, common_words: Arc<CommonWords>,
@ -28,9 +31,6 @@ pub struct HttpServer {
db: Arc<DB>, db: Arc<DB>,
} }
#[derive(Debug, Deserialize)]
struct SearchQuery { q: String }
impl HttpServer { impl HttpServer {
pub fn from_command(command: CommandHttp) -> io::Result<HttpServer> { pub fn from_command(command: CommandHttp) -> io::Result<HttpServer> {
let common_words = common_words::from_file(command.stop_words)?; let common_words = common_words::from_file(command.stop_words)?;