https://github.com/zippoxer/lazysearch-php
A PHP client for full-text search with lazysearch
https://github.com/zippoxer/lazysearch-php
Last synced: 5 months ago
JSON representation
A PHP client for full-text search with lazysearch
- Host: GitHub
- URL: https://github.com/zippoxer/lazysearch-php
- Owner: zippoxer
- Created: 2018-03-24T17:42:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-31T15:24:52.000Z (about 8 years ago)
- Last Synced: 2026-01-14T13:56:35.857Z (5 months ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Full-Text Search for PHP with [marco](http://marco.zippo.io)
Empower your PHP application with powerful full-text search.
## Installation
```
composer require zippoxer/marco
```
## Usage
Insert a document to folder `people`:
```php
$client = new Marco\Client('your-api-key');
$client->people->put('1', [
'name' => 'David',
'age' => 35,
'about' => 'I like pizza.'
]);
```
Search it:
```php
$results = $client->people->search('pizza');
foreach($results['hits'] as $person) {
echo $person->name;
}
```
Advanced search:
```php
$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 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;
}
```
For more details, see documentation at [lazysearch.zippo.io](http://lazysearch.zippo.io)