本地文件
在这篇教程中,我们将介绍如何使用 Quickwit 命令行界面来索引本地文件。
要跟随这篇教程,您需要有Quickwit 二进制文件。
Create an index(创建索引)
首先,我们创建一个无模式的索引。我们需要仅为了创建索引而启动 Quickwit 服务器 ,因此我们将启动它并在之后关闭它。
启动 Quickwit server。
./quickwit run
在另一个终端中创建索引。
# Create the index config file.
cat << EOF > stackoverflow-schemaless-config.yaml
version: 0.7
index_id: stackoverflow-schemaless
doc_mapping:
mode: dynamic
indexing_settings:
commit_timeout_secs: 30
EOF
./quickwit index create --index-config stackoverflow-schemaless-config.yaml
现在您可以通过在第一个终端中按下 Ctrl+C
来关闭服务器。
Ingest the file(摄取文件)
要发送文件,只需执行以下命令:
./quickwit tool local-ingest --index stackoverflow-schemaless --input-path stackoverflow.posts.transformed-10000.json
几秒钟后,您应该能看到以下输出:
❯ Ingesting documents locally...
---------------------------------------------------
Connectivity checklist
✔ metastore
✔ storage
✔ _ingest-cli-source
Num docs 10000 Parse errs 0 PublSplits 1 Input size 6MB Thrghput 3.34MB/s Time 00:00:02
Num docs 10000 Parse errs 0 PublSplits 1 Input size 6MB Thrghput 2.23MB/s Time 00:00:03
Num docs 10000 Parse errs 0 PublSplits 1 Input size 6MB Thrghput 1.67MB/s Time 00:00:04
Indexed 10,000 documents in 4s.
Now, you can query the index with the following command:
quickwit index search --index stackoverflow-schemaless --config ./config/quickwit.yaml --query "my query"
Clearing local cache directory...
✔ Local cache directory cleared.
✔ Documents successfully indexed.
tip
支持像 s3://mybucket/mykey.json
这样的对象存储 URI 作为 --input-path
,前提是您的环境配置了适当的权限。
Tear down resources(清理资源:可选)
就这样!现在您可以清理创建的资源。您可以通过运行以下命令来完成:
./quickwit run
在另一个终端中:
./quickwit index delete --index-id stackoverflow-schemaless
至此完成了教程。现在您可以继续阅读下一教程。