brighttalk / acs-query-builder
Provides an object oriented way to programmatically build queries for the Amazon Cloud Search service
Installs: 12 537
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 10
Forks: 4
Open Issues: 1
Requires
- php: >=5.3.3
Requires (Dev)
- mockery/mockery: 0.9.*
- phpunit/phpunit: 4.4.*
This package is not auto-updated.
Last update: 2024-12-21 15:39:31 UTC
README
Description
This library provides an object oriented way to programmatically build queries for the Amazon Cloud Search service. It's inspired by Doctrine's query builder. A query's __toString method will return a decoded string, as provided by the http_build_query function
##Installation
Add to your composer.json:
"require": {
...
"brighttalk/acs-query-builder": "dev-master"
}
Working with the Query Builder
$query = $qb->searchByFieldValue("fieldName", "'fieldValue'") ->setSize(20) ->setStart(0) ->setRank('-fieldName') ->getQuery(); echo $query;
would output bq=fieldName:'fieldValue'&start=0&size=20&rank=-fieldName (the "-" in the rank expression means it is in descending order - see the Amazon docs )
The ExpressionBuilder
The supported expressions are: andX, orX, notX, eq
Example:
$query = $qb->setSearchExpression($qb->expr()->andx( $qb->expr()->eq("aFieldName", "'aFieldValue'"), $qb->expr()->notx($qb->expr()->eq("anotherFieldName", "'anotherFieldValue'")) )) ->setSize(20) ->setStart(0) ->getQuery(); echo $query;
would output bq=(and afieldName:'afieldValue' (not anotherFieldName:'anotherFieldValue'))&start=0&size=20