# bayard-cli search

## DESCRIPTION

Search documents from index server

## USAGE

bayard-cli search [FLAGS] [OPTIONS]

## FLAGS

- `-c`, `--exclude-count`
  A flag indicating whether or not to exclude hit count in the search results.

- `-d`, `--exclude-docs`
  A flag indicating whether or not to exclude hit documents in the search results

- `-h`, `--help`
  Prints help information.

- `-v`, `--version`
  Prints version information.

## OPTIONS

- `-s`, `--server` `<IP:PORT>`
  Index service address. [default: 127.0.0.1:5000]

- `-f`, `--from` `<FROM>`
  Start position of fetching results. [default: 0]

- `-l`, `--limit` `<LIMIT>`
  Limitation of amount that document to be returned. [default: 10]

- `-F`, `--facet-field` `<FACET_FIELD>`
  Hierarchical facet field name. [default: ]

- `-V`, `--facet-prefix` `<FACET_PREFIX>...`
  Hierarchical facet field value prefix.

## ARGS

- `<QUERY>`
  Query string to search the index.

## EXAMPLES

To search documents from the index with options:

    $ bayard-cli search \
                 --server=0.0.0.0:5001 \
                 --facet-field=category \
                 --facet-prefix=/category/search \
                 --facet-prefix=/language \
                 description:rust | jq .

You'll see the result in JSON format. The result of the above command is:

    {
      "count": 2,
      "docs": [
        {
          "fields": {
            "_id": [
              "8"
            ],
            "category": [
              "/category/search/library",
              "/language/rust"
            ],
            "description": [
              "Tantivy is a full-text search engine library inspired by Apache Lucene and written in Rust."
            ],
            "name": [
              "Tantivy"
            ],
            "popularity": [
              3142
            ],
            "timestamp": [
              "2019-12-19T01:07:00+00:00"
            ],
            "url": [
              "https://github.com/tantivy-search/tantivy"
            ]
          },
          "score": 1.5722498
        },
        {
          "fields": {
            "_id": [
              "1"
            ],
            "category": [
              "/category/search/server",
              "/language/rust"
            ],
            "description": [
              "Bayard is a full text search and indexing server, written in Rust, built on top of Tantivy."
            ],
            "name": [
              "Bayard"
            ],
            "popularity": [
              1152
            ],
            "timestamp": [
              "2019-12-19T01:41:00+00:00"
            ],
            "url": [
              "https://github.com/bayard-search/bayard"
            ]
          },
          "score": 1.5331805
        }
      ],
      "facet": {
        "category": {
          "/language/rust": 2,
          "/category/search/library": 1,
          "/category/search/server": 1
        }
      }
    }