Commit 2d966976 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Patching search/elasticsearch to work with elasticsearch 0.9 and 1.5"

parents 882fba65 43912094
......@@ -1227,14 +1227,14 @@ class ElasticsearchPseudotype_all
$elasticaQuery = new \Elastica\Query();
$elasticaQuery->setFrom($offset);
$elasticaQuery->setLimit($limit);
$elasticaQuery->setQuery($elasticaQueryString);
$elasticaFilterAnd = new \Elastica\Filter\BoolAnd();
// Apply ACL filters
$elasticaFilterACL = new ElasticsearchFilterAcl($USER);
$elasticaFilterAnd->addFilter($elasticaFilterACL);
$elasticaQuery->setFilter($elasticaFilterAnd);
$elasticaFilteredQuery = new \Elastica\Query\Filtered($elasticaQueryString, $elasticaFilterAnd);
$elasticaQuery->setQuery($elasticaFilteredQuery);
// Define a new facet: mainFacetTerm - WARNING: don't forget to apply the same filter to the facet
$elasticaFacet = new \Elastica\Facet\Terms('mainFacetTerm');
......@@ -1263,10 +1263,12 @@ class ElasticsearchPseudotype_all
$elasticaFilterType = new \Elastica\Filter\Term(array('mainfacetterm' => $result['selected']));
$elasticaFilterAnd->addFilter($elasticaFilterType);
$elasticaQuery->setFilter($elasticaFilterAnd);
$elasticaFilteredQuery = new \Elastica\Query\Filtered($elasticaQueryString, $elasticaFilterAnd);
$elasticaQuery->setQuery($elasticaFilteredQuery);
// Define a new facet: secFacetTerm - WARNING: don't forget to apply the same filter to the facet
$elasticaFacet = new \Elastica\Facet\Terms('secFacetTerm');
$elasticaFacet = new \Elastica\Facet\Terms('secFacetTerm');
$elasticaFacet->setField('secfacetterm');
$elasticaFacet->setOrder('count');
$elasticaFacet->setFilter($elasticaFilterAnd);
......@@ -1319,7 +1321,8 @@ class ElasticsearchPseudotype_all
$elasticaFilterAnd->addFilter($elasticaFilterLicense);
}
$elasticaQuery->setFilter($elasticaFilterAnd);
$elasticaFilteredQuery = new \Elastica\Query\Filtered($elasticaQueryString, $elasticaFilterAnd);
$elasticaQuery->setQuery($elasticaFilteredQuery);
$elasticaResultSet = $elasticaIndex->search($elasticaQuery);
$elasticaResults = $elasticaResultSet->getResults();
$result['count'] = $elasticaResultSet->getTotalHits();
......
......@@ -420,7 +420,8 @@ class ElasticsearchType_artefact extends ElasticsearchType
$elasticaFilterACL = new ElasticsearchFilterAcl($USER);
$elasticaFilterAnd->addFilter($elasticaFilterACL);
$elasticaQuery->setFilter($elasticaFilterAnd);
$elasticaFilteredQuery = new \Elastica\Query\Filtered(null, $elasticaFilterAnd);
$elasticaQuery->setQuery($elasticaFilteredQuery);
$elasticaResultSet = $elasticaIndex->search($elasticaQuery);
$elasticaResults = $elasticaResultSet->getResults();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment