Nextcloud で使う Full text search – Elasticsearch Platform が更新されたので Elasticsearch を 7 から 8 へ入れ替えた

Nextcloud で全文検索を行うプラグインが更新されて、Elasticsearch 7.XX では動かなくなり 8.XX へ変更する必要がありました
以前、8.XX をテストしたことがあったので、簡単に移行できるかと思ったが甘かった…

0.はじまり

Full text search – Elasticsearch プラグインのバージョンが 26.XX 以降は Elasticsearch 8 移行が必要になったそうで、7.XX では全文検索ができなくなりました
暫く 全文検索のプラグインは更新しないで運用していけれど、うっかりプラグインを全更新してしまい、全文検索が使えなくなってしまった
 
そこで、Elasticsearch を 7 から 8 へ変更しました
 
Elasticsearch は、起草時点で最新の Eelasticsearch-8.11.4-windows-x86_64 を拾ってきて解凍しました
 

1.Elasticsearch の準備

特に難しいことはなく、解凍して Elasticsearch 7 の時のフォルダーと入れ替えただけで動く
先に、設定ファイルを修正しておけば問題ないが、その結論に至るまでに紆余曲折が…
 
config/jvm.options で、メモリーの使用量を前回と同様に制限します

## IMPORTANT: JVM heap size

-Xms512m
-Xmx512m


 
elasticsearch.yml で、アドレスとポートを指定します

---------------------------------- Network -----------------------------------
#

#network.host: 192.168.0.1
network.host: 172.16.XXX.XXX

#http.port: 9200
http.port: 9200


 
結論を先に…
 

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------

# Enable security features
#xpack.security.enabled: true
xpack.security.enabled: false


https でも問題ないと思いましたが、社内用の接続ですので、結果的に http で接続しました
 

2.動作確認

前回と同様に、Windows で bin/elasticsearch.bat を起動します
 
文字化けしていますが、初回起動時(data フォルダーをクリアクリアしても)パスワードを生成するようです


邃ケ・・ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
_W*s+PLj0ebkbDXXXXXX
 
邃ケ・・ HTTP CA certificate SHA-256 fingerprint:
d52e83a274ea09a7f997fee86d531b36d514c2e2f82109ca93831984XXXXXXXX
 
邃ケ・・ Configure Kibana to use this cluster:
窶「 Run Kibana and click the configuration link in the terminal when Kibana starts.
窶「 Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjExLjQiLCJhZHIiOlsiMTcyLjE2LjIwNS4xMjA6OTIwMCJdLCJmZ3IiOiJkNTJlODNhMjc0ZWEwOWE3Zjk5N2ZlZTg2ZDUzMWIzNmQ1MTRjMmUyZjgyMTA5Y2E5MzgzMTk4NGE2N2ZkNWU3Iiwia2V5Ijoia2RINkVJMEJWS3oxaU5kTWdnMlI6TGU1X1hmOHZRdzJZSVVITnXXXXXXXXXX
 
邃ケ・・ Configure other nodes to join this cluster:
窶「 On this node:
竅・Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`.
竅・Uncomment the transport.host setting at the end of config/elasticsearch.yml.
竅・Restart Elasticsearch.
窶「 On other nodes:
竅・Start Elasticsearch with `bin/elasticsearch --enrollment-token `, using the enrollment token that you generated.
笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤笏≫煤

 
 

 
表示されたパスワードを覚えて於いて、URL などで指定します
 
最初に、コマンドプロンプトから curl.exe で接続してみます

C:\elasticsearch\bin>curl.exe "https://elastic:_W*s+PLj0ebkbDXXXXXX@127.0.0.1:9200" -k
{
"name" : "DESKTOP-XXXXXXX",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "ApC5eb5rRpebhdmXXXXXXX",
"version" : {
"number" : "8.11.4",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "da06c53fd49b7e676ccf8a32d6655c51XXXXXXXX",
"build_date" : "2024-01-08T10:05:08.438562403Z",
"build_snapshot" : false,
"lucene_version" : "9.8.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
 
C:\elasticsearch\bin>
 

 
 
ブラウザーで接続してみます

ユーザー名は elastic で、パスワードは上のログに表示されています
この時点では elasticsearch.yml の xpack.security.enabled は true の設定です
 
きちんと version – number で 8.11.4 が帰ってきています
問題は無いようです
 

3.Nextcloud で確認する

Nextcloud が動いている機体で occ コマンドを使って動作確認してみます
 
最初に Nextcloud の 全文検索の設定を変更しておきます
 

 
※ ここでは http 接続に設定してありますが、 https で接続する場合は、アドレスを併せて https://elastic:_W*s+PLj0ebkbDXXXXXX@172.16.XXX.XXX:9200 を指定します
 
occ コマンドを実行します

user@user:/var/www/nextcloud$ sudo -u www-data -g www-data php -f occ fulltextsearch:check
Full text search 27.0.3
 
- Search Platform:
Elasticsearch 27.0.5 (Selected)
{
"elastic_host": [
"https://elastic:_W*s+PLj0ebkbDXXXXXX@172.16.XXX.XXX:9200"
],
"elastic_index": "nextclouid_index",
"fields_limit": "10000",
"es_ver_below66": "0",
"elastic_logger_enabled": "1",
"analyzer_tokenizer": "standard",
"allow_self_signed_cert": "false"
}
 
- Content Providers:
Files 27.0.1
{
"files_local": "1",
"files_external": "0",
"files_group_folders": "0",
"files_encrypted": "0",
"files_federated": "0",
"files_size": "32768",
"files_pdf": "1",
"files_office": "1",
"files_image": "0",
"files_audio": "0",
"files_chunk_size": "2"
}
 
user@user:~$ sudo -u www-data -g www-data php -f /var/www/nextcloud/occ fulltextsearch:test
 
.Testing your current setup:
Creating mocked content provider. ok
Testing mocked provider: get indexable documents. (2 items) ok
Loading search platform. (Elasticsearch) ok
Testing search platform. ok
Locking process ok
Removing test. ok
Pausing 3 seconds 1 2 3 ok
Initializing index mapping. ok
Indexing generated documents. ok
Pausing 3 seconds 1 2 3 ok
Retreiving content from a big index (license). (size: 32386) ok
Comparing document with source. ok
Searching basic keywords:
- 'test' (result: 1, expected: ["simple"]) ok
- 'document is a simple test' (result: 2, expected: ["simple","license"]) ok
- '"document is a test"' (result: 0, expected: []) ok
- '"document is a simple test"' (result: 1, expected: ["simple"]) ok
- 'document is a simple -test' (result: 1, expected: ["license"]) ok
- 'document is a simple +test' (result: 1, expected: ["simple"]) ok
- '-document is a simple test' (result: 0, expected: []) ok
- 'document is a simple +test +testing' (result: 1, expected: ["simple"]) ok
- 'document is a simple +test -testing' (result: 0, expected: []) ok
- 'document is a +simple -test -testing' (result: 0, expected: []) ok
- '+document is a simple -test -testing' (result: 1, expected: ["license"]) ok
- 'document is a +simple -license +testing' (result: 1, expected: ["simple"]) ok
Updating documents access. ok
Pausing 3 seconds 1 2 3 ok
Searching with group access rights:
- 'license' - [] - (result: 0, expected: []) ok
- 'license' - ["group_1"] - (result: 1, expected: ["license"]) ok
- 'license' - ["group_1","Group_2"] - (result: 1, expected: ["license"]) ok
- 'license' - ["group_3","Group_2"] - (result: 1, expected: ["license"]) ok
- 'license' - ["group_3"] - (result: 0, expected: []) ok
Searching with share rights:
- 'license' - notuser - (result: 0, expected: []) ok
- 'license' - User number_2 - (result: 1, expected: ["license"]) ok
- 'license' - User3 - (result: 1, expected: ["license"]) ok
- 'license' - User@4 - (result: 1, expected: ["license"]) ok
Removing test. ok
Unlocking process ok
user@user:~$
 

特に問題ないようです
※ ウソです! 結構苦労しました 以下(ry…
 

4.インデックスの再作成

Elasticsearch の data フォルダーが空の場合は Elasticsearch を起動すると初期データーが用意され、ログにパスワードが表示されます
 
インデックスの再作成は occ fulltextsearch:index を実行するのですが、これが何度行っても失敗する
 
なので、elasticsearch.yml のセキュリティー設定を xpack.security.enabled: false に設定して Nextcloud のサーバーを再起動しました
※ その時は Nextcloud の全文検索のサーバー設定を上図のように http の設定にします
 
多分、xpack.security.enabled の設定値に因らず occ fulltextsearch:index を実行する前に、サーバーは再起動してその直後に実行するのが良いようです
 
これが判らず、設定をこねくり回しました
何度、occ fulltextsearch:test や occ fulltextsearch:reset と occ fulltextsearch:index を実施しても、live が動いていると言われてエラーします
もちろん、occ fulltextsearch:stop を実施しても live が止まりませんでした
 
これは以前も苦しんだ覚えがありますが、Nextcloud サーバーの再起動直後だとイケるようです
 
結局、社内の Windows 10 で Elasticsearch を動かしていますので、http で稼働させるようにしました
Windows の証明書とか、いつ更新されるか判んないし、その時トラブっても面倒だし….
 
Nextcloud サーバーを再起動した直後に occ fulltextsearch:index を実行してインデックスの再作成が成功した様なので完了としました
 

全文検索して、結果が帰ってきましたので良いのかな…
 
でも、Excel とかの中身を検索してない気がする…
 
あ、更新が掛かると検索されるなぁ…
occ の index の対象外なのかな…

5.追記

・ ingest-attachment プラグインが不要になったようです
  そもそも、インストールできませんでした

.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


The reCAPTCHA verification period has expired. Please reload the page.