LoginSignup
5
5

More than 5 years have passed since last update.

PHP用Elasticsearchクライント、Elasticaを使ってみる (3)

Posted at

indexもtypeも指定せずに検索したいわ!というとき

<?php
require_once '../vendor/autoload.php';

use Elastica\Client;
use Elastica\Search;
use Elastica\Query;
use Elastica\Query\MatchAll;

$client = new Client();
$search = new Search($client);
$query = Query::create(new MatchAll());
$total = $search->search($query)->getTotalHits();
var_dump($total);

SearchにClientを渡す。
これで全index、全typeを対象に検索できる。はず

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5