Commit 98a86ce7 by Klimov Paul

Sphinx distributed indexes support provided

parent 10d617a9
......@@ -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 #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 #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
......
......@@ -459,6 +459,8 @@ class Schema extends Object
}
throw $e;
}
if (empty($columns[0]['Agent'])) {
foreach ($columns as $info) {
$column = $this->loadColumnSchema($info);
$index->columns[$column->name] = $column;
......@@ -466,6 +468,11 @@ class Schema extends Object
$index->primaryKey = $column->name;
}
}
} else {
// Distributed index :
$agent = $this->getIndexSchema($columns[0]['Agent']);
$index->columns = $agent->columns;
}
return true;
}
......
......@@ -101,6 +101,13 @@ index yii2_test_rt_index
}
index yii2_test_distributed
{
type = distributed
local = yii2_test_article_index
}
indexer
{
mem_limit = 32M
......
......@@ -324,4 +324,27 @@ class QueryTest extends SphinxTestCase
->all($connection);
$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