|  | @@ -52,7 +52,9 @@ class Base extends ControllerBase {
 | 
	
		
			
				|  |  |      $parse_mode->setConjunction('AND');
 | 
	
		
			
				|  |  |      $this->and_query->setParseMode($parse_mode);
 | 
	
		
			
				|  |  |      // Set fulltext search keywords and fields.
 | 
	
		
			
				|  |  | -    $this->and_query->keys($this->keys);
 | 
	
		
			
				|  |  | +    if ($this->keys) {
 | 
	
		
			
				|  |  | +      $this->and_query->keys($this->keys);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      // in case of term id provided restrict the keys to taxo fields
 | 
	
		
			
				|  |  |      if ($this->term) {
 | 
	
	
		
			
				|  | @@ -83,6 +85,15 @@ class Base extends ControllerBase {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        $this->and_query->addConditionGroup($filters_conditions);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      if(!$this->keys) {
 | 
	
		
			
				|  |  | +        // if no keys but filters switch query to direct and add wildcard solr keys *:* 
 | 
	
		
			
				|  |  | +        $direct_and_parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')
 | 
	
		
			
				|  |  | +        ->createInstance('direct');
 | 
	
		
			
				|  |  | +        $direct_and_parse_mode->setConjunction('AND');
 | 
	
		
			
				|  |  | +        $this->and_query->setParseMode($direct_and_parse_mode);
 | 
	
		
			
				|  |  | +        // $this->and_query->keys('*:*');
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      // else{    
 | 
	
		
			
				|  |  |      $fulltextFields = [];
 | 
	
	
		
			
				|  | @@ -151,8 +162,9 @@ class Base extends ControllerBase {
 | 
	
		
			
				|  |  |      $this->or_query->setParseMode($or_parse_mode);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // Set fulltext search keywords and fields.
 | 
	
		
			
				|  |  | -    $this->or_query->keys($this->keys);
 | 
	
		
			
				|  |  | -    // $this->or_query->setFulltextFields(['field_reference']);
 | 
	
		
			
				|  |  | +    if ($this->keys) {
 | 
	
		
			
				|  |  | +      $this->or_query->keys($this->keys);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // exclude results from and_query
 | 
	
		
			
				|  |  |      $exclude_and_results_conditions = $this->or_query->createConditionGroup('AND');
 | 
	
	
		
			
				|  | @@ -180,6 +192,16 @@ class Base extends ControllerBase {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        $this->or_query->addConditionGroup($or_filters_conditions);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      if(!$this->keys) {
 | 
	
		
			
				|  |  | +        // if no keys but filters switch query to direct and add wildcard solr keys *:* 
 | 
	
		
			
				|  |  | +        $direct_or_parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')
 | 
	
		
			
				|  |  | +        ->createInstance('direct');
 | 
	
		
			
				|  |  | +        $direct_or_parse_mode->setConjunction('OR');
 | 
	
		
			
				|  |  | +        $this->or_query->setParseMode($direct_or_parse_mode);
 | 
	
		
			
				|  |  | +        // $this->or_query->keys('*:*');
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // Restrict the search to specific languages.
 | 
	
	
		
			
				|  | @@ -204,6 +226,9 @@ class Base extends ControllerBase {
 | 
	
		
			
				|  |  |        $this->results['uuids'][] = $result->getField('uuid')->getValues()[0];
 | 
	
		
			
				|  |  |        $this->results['nids'][] = $result->getField('nid')->getValues()[0];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // todo you may like / more like this
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    private function defaultQuery(){
 | 
	
	
		
			
				|  | @@ -264,21 +289,43 @@ class Base extends ControllerBase {
 | 
	
		
			
				|  |  |        ),
 | 
	
		
			
				|  |  |      ];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    if ($this->keys) {
 | 
	
		
			
				|  |  | +    if ($this->keys || $this->filters) {
 | 
	
		
			
				|  |  | +      $lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        $this->sapiQuery();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        $resp['keys'] = $this->keys;
 | 
	
		
			
				|  |  |        $resp['term'] = $this->term;
 | 
	
		
			
				|  |  | +      $resp['filters'] = $this->filters;
 | 
	
		
			
				|  |  |        // $resp['count'] = $this->results->getResultCount();
 | 
	
		
			
				|  |  |        $resp['count'] = count($this->results['nids']);
 | 
	
		
			
				|  |  |        $resp['exactematch_count'] = $this->exactematch_count;
 | 
	
		
			
				|  |  | -      $resp['infos'] = t('The search found @exactmatchcount exact match result(s) for @count total result(s) with keywords @keys', array(
 | 
	
		
			
				|  |  | +      $resp['infos'] = t('The search found @exactmatchcount exact match result(s) for @count total result(s) with', array(
 | 
	
		
			
				|  |  |          "@exactmatchcount" => $resp['exactematch_count'],
 | 
	
		
			
				|  |  | -        "@count" => $resp['count'],
 | 
	
		
			
				|  |  | -        "@keys" => $this->keys
 | 
	
		
			
				|  |  | +        "@count" => $resp['count']
 | 
	
		
			
				|  |  |        ));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +      if ($this->keys) {
 | 
	
		
			
				|  |  | +        $resp['infos'] .= t(' keywords @keys', array(
 | 
	
		
			
				|  |  | +          "@keys" => $this->keys
 | 
	
		
			
				|  |  | +        ));
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if ($this->keys && $this->filters) {
 | 
	
		
			
				|  |  | +        $resp['infos'] .= " and";
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if ($this->filters) {
 | 
	
		
			
				|  |  | +        // get the terms names from tid
 | 
	
		
			
				|  |  | +        $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
 | 
	
		
			
				|  |  | +        $filters_names = [];
 | 
	
		
			
				|  |  | +        foreach ($this->filters as $tid) {
 | 
	
		
			
				|  |  | +          /** @var \Drupal\Core\Entity\EntityInterface $entity */
 | 
	
		
			
				|  |  | +          $entity = $storage->load($tid);
 | 
	
		
			
				|  |  | +          $entity_trans = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $lang);
 | 
	
		
			
				|  |  | +          $filters_names[] = $entity_trans->getName();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $resp['infos'] .= t(' filters @filters', array(
 | 
	
		
			
				|  |  | +          "@filters" => implode(', ', $filters_names)
 | 
	
		
			
				|  |  | +        ));
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |        // $resp['options'] = $this->query->getOptions();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        // $uuids = [];
 |