/** * Method to create a filter by ES Type for all type. * For example if the search if just for article, * the filter we be on article, article_en-GB etc for each language */ private function createFilterType($plg_types) { //By default search in all types $all_types = true; $elasticaFilterType = new \Elastica\Filter\Terms("_type"); // Foreach existing ES types foreach ($plg_types as $area) { //Check if this type is enable for the search $check = JRequest::getString($area['type'], null, 'get'); if ($check != "") { $all_types = false; // Generate all type with language extension type_en-GB etc. $langTypes = $this->getTypesWithLang($area['type']); foreach ($langTypes as $type) { $elasticaFilterType->addTerm($type); } } } // If all_type still true, the search is for all content type foreach ($plg_types as $area) { if ($all_types) { foreach ($this->areas as $area) { $langTypes = $this->getTypesWithLang($area['type']); foreach ($langTypes as $type) { $elasticaFilterType->addTerm($type); } } } } return $elasticaFilterType; }