Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #124 from digiaonline/fix-readme
Browse files Browse the repository at this point in the history
Update the README, QueryBuilder has been removed
  • Loading branch information
Jalle19 committed May 20, 2019
2 parents 45a2729 + 3ed4c1f commit d32e863
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions README.md
Expand Up @@ -192,38 +192,36 @@ $service->index([

### Running queries

Queries against the search index are run by creating a query using the query builder, then creating a search using the
query and finally executing the query using the provided service.
Queries against the search index are run by creating a query, then creating a search using the query and finally
executing the query using the provided service.

Here's an example:

```php
// Get an instance of ElasticSearchService
$service = app(ElasticsearchServiceContract::class);

// Create a query builder
$queryBuilder = $service->createQueryBuilder();

// Create the query
$query = $queryBuilder->createBoolQuery()
$query = (new BoolQuery())
->addMust(
$queryBuilder->createTermQuery()
(new TermQuery())
->setField('user')
->setValue('kimchy'))
->addFilter(
$queryBuilder->createTermQuery()
(new TermQuery())
->setField('tag')
->setValue('tech'))
->addMustNot(
$queryBuilder->createRangeQuery()
(new RangeQuery())
->setField('age')
->setGreaterThanOrEquals(18)
->setLessThanOrEquals(40))
->addShould(
$queryBuilder->createTermQuery()
(new TermQuery())
->setField('tag')
->setValue('wow'))
->addShould(
$queryBuilder->createTermQuery()
(new TermQuery())
->setField('tag')
->setValue('elasticsearch'));

Expand Down

0 comments on commit d32e863

Please sign in to comment.