Commit 98a86ce7 by Klimov Paul

Sphinx distributed indexes support provided

parent 10d617a9
...@@ -6,6 +6,7 @@ Yii Framework 2 sphinx extension Change Log ...@@ -6,6 +6,7 @@ Yii Framework 2 sphinx extension Change Log
- Bug #3668: Escaping of the special characters at 'MATCH' statement added (klimov-paul) - Bug #3668: Escaping of the special characters at 'MATCH' statement added (klimov-paul)
- Bug #4018: AR relation eager loading does not work with db models (klimov-paul) - Bug #4018: AR relation eager loading does not work with db models (klimov-paul)
- Bug #4375: Distributed indexes support provided (klimov-paul)
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe) - Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue) - Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews) - Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
......
...@@ -459,12 +459,19 @@ class Schema extends Object ...@@ -459,12 +459,19 @@ class Schema extends Object
} }
throw $e; throw $e;
} }
foreach ($columns as $info) {
$column = $this->loadColumnSchema($info); if (empty($columns[0]['Agent'])) {
$index->columns[$column->name] = $column; foreach ($columns as $info) {
if ($column->isPrimaryKey) { $column = $this->loadColumnSchema($info);
$index->primaryKey = $column->name; $index->columns[$column->name] = $column;
if ($column->isPrimaryKey) {
$index->primaryKey = $column->name;
}
} }
} else {
// Distributed index :
$agent = $this->getIndexSchema($columns[0]['Agent']);
$index->columns = $agent->columns;
} }
return true; return true;
......
...@@ -101,6 +101,13 @@ index yii2_test_rt_index ...@@ -101,6 +101,13 @@ index yii2_test_rt_index
} }
index yii2_test_distributed
{
type = distributed
local = yii2_test_article_index
}
indexer indexer
{ {
mem_limit = 32M mem_limit = 32M
......
...@@ -324,4 +324,27 @@ class QueryTest extends SphinxTestCase ...@@ -324,4 +324,27 @@ class QueryTest extends SphinxTestCase
->all($connection); ->all($connection);
$this->assertNotEmpty($rows); $this->assertNotEmpty($rows);
} }
/**
* @depends testRun
*
* @see https://github.com/yiisoft/yii2/issues/4375
*/
public function testRunOnDistributedIndex()
{
$connection = $this->getConnection();
$query = new Query;
$rows = $query->from('yii2_test_distributed')
->match('about')
->options([
'cutoff' => 50,
'field_weights' => [
'title' => 10,
'content' => 3,
],
])
->all($connection);
$this->assertNotEmpty($rows);
}
} }
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