Platform.sh の Symfony 4.4 で FOS Elasticsearch バンドルを使用していますが、入力しようとするとエラーが発生します。
関連する構成要素:
composer.json
"require": {
"php": ">=7.3.0",
...
"friendsofsymfony/elastica-bundle": "^5.1",
プラットフォーム/services.yml
searchelastic77:
type: elasticsearch:7.7
disk: 1024
.platform.app.yml
relationships:
...
elasticsearch: "searchelastic77:elasticsearch"
config/packages/fos_elastica.yml
fos_elastica:
clients:
default: { url: '%env(ELASTICSEARCH_URL)%' }
indexes:
app_post:
types:
post:
properties:
title: ~
excerpt: ~
content: ~
author: ~
persistence:
driver: orm
model: App\Entity\Post
provider: ~
finder: ~
.env
###> friendsofsymfony/elastica-bundle ###
ELASTICSEARCH_URL=http://localhost:9200/
###< friendsofsymfony/elastica-bundle ###
このブランチの platform.sh 設定では、次の変数を構成しています。
env:ELASTICSEARCH_URL = http://elasticsearch.internal:9200
platform:relationships
このブランチで実行すると、次の結果が得られます。
elasticsearch:
-
service: searchelastic77
ip: ***
cluster: ***
host: elasticsearch.internal
rel: elasticsearch
scheme: http
port: 9200
url: 'http://elasticsearch.internal:9200'
エラーは、不適切な HTTP メソッドに関係しているようです。コマンドを実行してライブ サーバーにインデックスを設定しようとするbin/console fos:elastica:populate
と、次の例外が発生します。
Resetting app_post
In Http.php line 182:
Incorrect HTTP method for uri [/] and method [PUT], allowed: [GET, DELETE, HEAD]
fos:elastica:populate [--index [INDEX]] [--type [TYPE]] [--no-reset] [--no-delete] [--sleep SLEEP] [--ignore-errors] [--no-overwrite-format] [--first-page FIRST-PAGE] [--last-page LAST-PAGE] [--max-per-page MAX-PER-PAGE] [--pager-persister PAGER-PERSISTER] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
運用サーバーで投稿エンティティを更新しようとすると、次のエラーも発生します。
request.CRITICAL: Uncaught PHP Exception Elastica\Exception\ResponseException: "Incorrect HTTP method for uri [/] and method [POST], allowed: [GET, DELETE, HEAD]" at /app/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php line 182 {"exception":"[object] (Elastica\\Exception\\ResponseException(code: 0): Incorrect HTTP method for uri [/] and method [POST], allowed: [GET, DELETE, HEAD] at /app/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php:182)"} []
エラスティック検索バージョン (5.2、6.5、現在は 7.7) のさまざまな組み合わせを試しましたが、すべて同じエラーがスローされます。