zippoxer/lazysearch
此包最新版本(dev-master)没有可用的许可证信息。
lazysearch 的 PHP 客户端,用于全文搜索
dev-master
2018-03-31 15:24 UTC
Requires
- php: >=5.4
- guzzlehttp/guzzle: ~6.0
This package is auto-updated.
Last update: 2024-09-04 22:38:46 UTC
README
用强大的全文搜索功能增强您的 PHP 应用程序。
安装
composer require zippoxer/marco
用法
将文档插入 people
文件夹
$client = new Marco\Client('your-api-key'); $client->people->put('1', [ 'name' => 'David', 'age' => 35, 'about' => 'I like pizza.' ]);
搜索它
$results = $client->people->search('pizza'); foreach($results['hits'] as $person) { echo $person->name; }
高级搜索
$results = $client->people->search('piz', [ // Leave empty for standard query. Other options are: 'prefix', 'phrase' and 'advanced'. 'queryType' => 'prefix', // Which field in the documents to search? Default is '*' (all fields). 'field' => 'name', // Which fields from the documents to return? Default is '*' (all fields). 'fields' => 'name,age,country', // How to sort the results? default is by _score descending (most relevant first). // Examples: // * 'age' sorts by field 'age' ascending // * '-age' sorts by field 'age' descending (reverse order) // * '-age,register_date' sorts by field 'age' descending, // then by field 'register_date' 'sort' => 'age', // Allow a specified number of typos in the search query. Default is 0 (no typos allowed). 'typos' => 1, // Highlight matched words with HTML <mark> tags. Default is false. 'highlight' => true, // Pagination. 'page' => 2, // Default is 1. 'hitsPerPage' => 50 // Default is 10. ]); foreach($results['hits'] as $person) { echo $person->name; }
更多详细信息,请参阅 lazysearch.zippo.io 的文档