/**
  * Data provider for testIteration.
  *
  * @return array
  */
 public function getIterationData()
 {
     $out = [];
     // Case #0: no search type set, with a sort, results should be sorted.
     $search = new Search();
     $search->setSize(2);
     $search->setScroll('1m');
     $search->addSort(new Sort('header'));
     $search->addQuery(new MatchAllQuery());
     $out[] = ['search' => $search, true];
     // Case #1: search type set to scan, with a sort, results should not be sorted.
     $search = new Search();
     $search->setSize(2);
     $search->setScroll('1m');
     $search->setSearchType('scan');
     $search->addSort(new Sort('header'));
     $search->addQuery(new MatchAllQuery());
     $out[] = ['search' => $search, false];
     // Case #3: minimum size, should give the same results.
     $search = new Search();
     $search->setSize(1);
     $search->setScroll('1m');
     $search->addSort(new Sort('header'));
     $search->addQuery(new MatchAllQuery());
     $out[] = ['search' => $search, true];
     return $out;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function modifySearch(Search $search, FilterState $state = null, SearchRequest $request = null)
 {
     if ($state && $state->isActive()) {
         $stateValue = $state->getValue();
         if (!empty($this->choices[$stateValue]['fields'])) {
             foreach ($this->choices[$stateValue]['fields'] as $sortField) {
                 $search->addSort(new EsSort($sortField['field'], $sortField['order'], null, $sortField['mode']));
             }
         } else {
             $sortField = $this->choices[$stateValue];
             $search->addSort(new EsSort($sortField['field'], $sortField['order'], null, $sortField['mode']));
         }
     } else {
         foreach ($this->choices as $choice) {
             if ($choice['default']) {
                 $search->addSort(new EsSort($choice['field'], $choice['order']));
                 break;
             }
         }
     }
 }