Post ツール
Solr には、`bin/solr` CLI の一部である、さまざまなタイプのコンテンツを Solr サーバーに POST するためのシンプルなコマンドラインツールが含まれています。
このツールは、Solr の機能を探求する新しいユーザーが使用することを目的としており、本番システムにドキュメントをインデックスするために使用される堅牢なソリューションとしては意図されていません。 |
SimplePostTool と `bin/post` Unix シェルスクリプトに精通しているかもしれません。これらはまだ利用可能ですが、非推奨となっており、Solr 10 では削除される予定です。 |
実行するには、ウィンドウを開いて次のように入力します。
$ bin/solr post -url https://127.0.0.1:8983/gettingstarted/update example/films/films.json
これは `localhost:8983` のサーバーに接続します。 `-help` (または単に `-h`) オプションは、その使用方法に関する情報を出力します (例: `bin/solr post -help`)。
bin/solr post ツールの使用
`bin/solr post` を使用する場合、更新ハンドラへのフルパスである `url` を指定するか、`c` コレクション/コア名を指定する必要があります。
これは同じターゲットコレクションを指定します: `-url https://127.0.0.1:8983/gettingstarted/update` または `-c gettingstarted`.
`bin/solr post` の基本的な使い方は次のとおりです。
$ bin/solr post -h
Usage: post -url https://127.0.0.1:8983/gettingstarted/update [OPTIONS] <files|directories|urls|-d ["...",...]>
or post -help
OPTIONS
=======
Solr options:
-url <base Solr update URL>
-commit issue a commit
-u or -user <user:pass> (sets BasicAuth credentials)
Web crawl options:
-recursive <depth> (default: 1)
-delay <seconds> (default: 10)
Directory crawl options:
-delay <seconds> (default: 0)
stdin/args options:
-type <content/type> (default: application/json)
Other options:
-filetypes <type>[,<type>,...] (default: xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log)
-params "<key>=<value>[&<key>=<value>...]" (values must be URL-encoded; these pass through to Solr update request)
-out output the Solr responses to console
-format solr (sends application/json content as Solr commands to /update instead of /update/json/docs
Examples:
* JSON file: bin/solr post -url https://127.0.0.1:8983/wizbang/update events.json
* XML files: bin/solr post -url https://127.0.0.1:8983/records/update article*.xml
* CSV file: bin/solr post -url https://127.0.0.1:8983/signals/update LATEST-signals.csv
* Directory of files: bin/solr post -filetypes xml,json,csv -url https://127.0.0.1:8983/myfiles/update ~/Documents
* Web crawl: bin/solr post -mode web -url https://127.0.0.1:8983/gettingstarted/update -recursive 1 -delay 1 https://solr.dokyumento.jp/
* Standard input (stdin): echo '{commit: {}}' | bin/solr post -mode stdin -url https://127.0.0.1:8983/my_collection/update -out
* Data as string: bin/solr post -url https://127.0.0.1:8983/signals/update -mode args -type text/csv -out $'id,value\n1,0.47'
bin/solr post の使用例
`bin/solr post` を使用するには、いくつかの方法があります。このセクションでは、いくつかの例を紹介します。
XML のインデクシング
ファイル拡張子が `.xml` のすべてのドキュメントを `gettingstarted` という名前のコレクションに追加します。
bin/solr post -url https://127.0.0.1:8983/solr/gettingstarted/update *.xml
ポート `8984` で実行されている Solr の `gettingstarted` コレクションに、ファイル拡張子が `.xml` のすべてのドキュメントを追加します。
bin/solr post -url https://127.0.0.1:8984/solr/gettingstarted/update *.xml
`gettingstarted` からドキュメントを削除するために XML 引数を送信します。
bin/solr post -url https://127.0.0.1:8983/solr/gettingstarted/update -mode args -type application/xml '<delete><id>42</id></delete>'
CSV と JSON のインデクシング
現在のディレクトリからすべての CSV および JSON ファイルを `gettingstarted` にインデックスします
bin/solr post -c gettingstarted -filetypes json,csv .
タブ区切りファイルを `gettingstarted` にインデックスします
bin/solr post -url https://127.0.0.1:8984/solr/signals/update -params "separator=%09" -type text/csv data.tsv
コンテンツタイプ (`-type`) パラメータは、ファイルを適切なタイプとして扱うために必要です。そうでない場合、ファイルは無視され、`.tsv` ファイルのコンテンツタイプがわからないため、警告がログに記録されます。CSV ハンドラ は `separator` パラメータをサポートしており、`-params` 設定を使用して渡されます。
JSON のインデクシング
すべての JSON ファイルを `gettingstarted` にインデックスします。
bin/solr post -url https://127.0.0.1:8983/solr/gettingstarted/update *.json
リッチドキュメント (PDF、Word、HTML など) のインデクシング
PDF ファイルを `gettingstarted` にインデックスします。
bin/solr post -url https://127.0.0.1:8983/solr/gettingstarted/update a.pdf
フォルダ内のコンテンツタイプを自動的に検出し、再帰的にスキャンして `gettingstarted` にインデックスするドキュメントを検索します。
bin/solr post -url https://127.0.0.1:8983/solr/gettingstarted/update afolder/
フォルダ内のコンテンツタイプを自動的に検出しますが、PPT および HTML ファイルに制限し、`gettingstarted` にインデックスします。
bin/solr post -url https://127.0.0.1:8983/solr/gettingstarted/update -filetypes ppt,html afolder/