Elasticsearch completion suggester query in PHP

后端 未结 2 613
盖世英雄少女心
盖世英雄少女心 2021-01-24 11:05

I was not able to find a working example on how to query Elasticsearch using the completion suggester in PHP (elasticsearch-php).

Querying via CURL, e.g.



        
2条回答
  •  礼貌的吻别
    2021-01-24 11:34

    The PHP ES client has a method called suggest that you can use for that purpose:

    $params = [
        'index' => 'tstidx',
        'body' => [
            'try' => [
                'text' => 'a',
                'completion' => [ 'field' => 'suggest' ]
            ]
        ]
    ];
    
    $client = ClientBuilder::create()->build();
    $response = $client->suggest($params);
    

提交回复
热议问题