protected function ElasticsearchTest::searchSuccess2 in Elasticsearch Connector 8
Same name and namespace in other branches
- 8.2 src/Tests/ElasticsearchTest.php \Drupal\elasticsearch_connector\Tests\ElasticsearchTest::searchSuccess2()
File
- src/
Tests/ ElasticsearchTest.php, line 184 - Contains \Drupal\elasticsearch_connector\Tests\ElasticsearchTest.
Class
- ElasticsearchTest
- Tests index and search capabilities using the elasticsearch backend.
Namespace
Drupal\elasticsearch_connector\TestsCode
protected function searchSuccess2() {
/*
$prepareSearch = $this->buildSearch('test')->range(1, 2);
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 4, 'Search for »test« returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(4, 1)), 'Search for »test« returned correct result.');
$this->assertIgnored($results);
$this->assertWarnings($results);
$prepareSearch = $this->buildSearch(NULL, array('body,test foobar'));
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 1, 'Search with multi-term fulltext filter returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(3)), 'Search with multi-term fulltext filter returned correct result.');
$this->assertIgnored($results);
$this->assertWarnings($results);
$prepareSearch = $this->buildSearch('test foo');
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 4, 'Search for »test foo« returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(2, 4, 1, 3)), 'Search for »test foo« returned correct result.');
$this->assertIgnored($results, array('foo'), 'Short key was ignored.');
$this->assertWarnings($results);
$prepareSearch = $this->buildSearch('foo', array('type,item'));
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 3, 'Search for »foo« returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(1, 2, 3)), 'Search for »foo« returned correct result.');
$this->assertIgnored($results, array('foo'), 'Short key was ignored.');
$this->assertWarnings($results, array($this->t('No valid search keys were present in the query.')), 'No warnings were displayed.');
$keys = array(
'#conjunction' => 'AND',
'test',
array(
'#conjunction' => 'OR',
'baz',
'foobar',
),
array(
'#conjunction' => 'OR',
'#negation' => TRUE,
'bar',
'fooblob',
),
);
$prepareSearch = $this->buildSearch($keys);
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 1, 'Complex search 1 returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(3)), 'Complex search 1 returned correct result.');
$this->assertIgnored($results, array('baz', 'bar'), 'Correct keys were ignored.');
$this->assertWarnings($results);
$keys = array(
'#conjunction' => 'AND',
'test',
array(
'#conjunction' => 'OR',
'baz',
'foobar',
),
array(
'#conjunction' => 'OR',
'#negation' => TRUE,
'bar',
'fooblob',
),
);
$prepareSearch = $this->buildSearch($keys);
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 1, 'Complex search 2 returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(3)), 'Complex search 2 returned correct result.');
$this->assertIgnored($results, array('baz', 'bar'), 'Correct keys were ignored.');
$this->assertWarnings($results);
$prepareSearch = $this->buildSearch(NULL, array('keywords,orange'));
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 3, 'Filter query 1 on multi-valued field returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(1, 2, 5)), 'Filter query 1 on multi-valued field returned correct result.');
$this->assertIgnored($results);
$this->assertWarnings($results);
$filters = array(
'keywords,orange',
'keywords,apple',
);
$prepareSearch = $this->buildSearch(NULL, $filters);
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 1, 'Filter query 2 on multi-valued field returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(2)), 'Filter query 2 on multi-valued field returned correct result.');
$this->assertIgnored($results);
$this->assertWarnings($results);
$prepareSearch = $this->buildSearch()->condition($this->getFieldId('keywords'), NULL);
sleep(1);
$results = $prepareSearch->execute();
$this->assertEqual($results->getResultCount(), 1, 'Query with NULL filter returned correct number of results.');
$this->assertEqual(array_keys($results->getResultItems()), $this->getItemIds(array(3)), 'Query with NULL filter returned correct result.');
$this->assertIgnored($results);
$this->assertWarnings($results);
*/
}