Created
August 8, 2015 15:14
-
-
Save gordonbanderson/e86bcdc43db550bcc7e1 to your computer and use it in GitHub Desktop.
Example of how to aggregate with filtering using Elastica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$queryString = new QueryString($_GET['q']); | |
$isoTerm = new Term(); | |
$isoTerm->setTerm('ISO',4000); | |
$apeterm = new Term(); | |
$apeterm->setTerm('Aperture',2.7); | |
$andFilter = new BoolAnd(); | |
$andFilter->addFilter($apeterm); | |
$andFilter->addFilter($isoTerm); | |
$filter = new Filtered( | |
$queryString, | |
$andFilter | |
/*new Range('published', array( | |
'from' => '2012-01-01 00:00:00', | |
'to' => '2013-01-01 00:00:00', | |
))*/ | |
); | |
$query = new Query($filter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The documentation for Elastica has no examples of how to this. The logic is this:
In the case of step 4) and there only being one filter, simply add that and skip the creation of the Boolean And filter. In the case of no facets chosen simply do not add the filter parameter.