php elasticsearch For input string: 2188,24

118
05 января 2020, 23:10

Добрый день помогите разобраться

    $response = $this->client->search([
        'index' => 'build',
        'type' => 'projects',
        'body' => [
            '_source' => ['id'],
            'query' => [
             'constant_score' => [
             'filter' => [
                'bool' => [
                    'must' => array_merge(
                        array_filter([
                     'terms' => [
                         'metro_id' => [$form->metro_id] 
                         ],
                        ])
                    )
                ],
            ],
            ],
        ],
        ],
    ]);

по GET получаю такую бороду

{
    "error": {
        "root_cause": [{
            "type": "query_shard_exception",
            "reason": "failed to create query: {\n \"constant_score\" : {\n \"filter\" : {\n \"bool\" : {\n \"must\" : [\n {\n \"terms\" : {\n \"metro_id\" : [\n \"2188,24\"\n ],\n \"boost\" : 1.0\n }\n }\n ],\n \"adjust_pure_negative\" : true,\n \"boost\" : 1.0\n }\n },\n \"boost\" : 1.0\n }\n}",
            "index_uuid": "egEl6aRnQXyAxXBbnLz4QA",
            "index": "build"
        }],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [{
            "shard": 0,
            "index": "build",
            "node": "HW4qeTViT4mXG4czKitPAg",
            "reason": {
                "type": "query_shard_exception",
                "reason": "failed to create query: {\n \"constant_score\" : {\n \"filter\" : {\n \"bool\" : {\n \"must\" : [\n {\n \"terms\" : {\n \"metro_id\" : [\n \"2188,24\"\n ],\n \"boost\" : 1.0\n }\n }\n ],\n \"adjust_pure_negative\" : true,\n \"boost\" : 1.0\n }\n },\n \"boost\" : 1.0\n }\n}",
                "index_uuid": "egEl6aRnQXyAxXBbnLz4QA",
                "index": "build",
                "caused_by": {
                    "type": "number_format_exception",
                    "reason": "For input string: \"2188,24\""
                }
            }
        }]
    },
    "status": 400
}

дынные

$_GET = [
    'metro_id' => '2188,24',
];

Когда делаю так все работает просто тест!

'terms' => [
'metro_id' => [1,2,3,4,5] или даже так ['1','2','3','4','5'] или c " тоже работает
 ],
]

Не могу понять причины, за ранее спасибо.

Answer 1

'metro_id' => [$form->metro_id]

замените на:

'metro_id' => explode(',', $form->metro_id)

READ ALSO
Yii2 Вывод данных в GridView

Yii2 Вывод данных в GridView

У меня есть сессия которая содержит множество id из БД мне нужно на основе этих id вывести GrideView как это можно реализовать максимально лаконично?

119
Как записать в html файл код скопированного div?

Как записать в html файл код скопированного div?

Как записать код копии div в html файл? С помощью этого кода делаю копию div, но скопирован div выводится только на экран и не записывается в файл...

143
Мобильный детектор, обнаружение картинки

Мобильный детектор, обнаружение картинки

Как сделать так чтобы при открытии главной страницы сайта через десктоп показывало видео, а при мобильном входе, то картинки, я скачал mobiledetector...

105