我正在使用Elasticsearch,并且我具有数组类型的给定字段,即:
cities = [ 15, 17, 23, 19 ]
如何使用\ yii \ elasticsearch \ ActiveRecord,我可以过滤以下内容:
[Registry contains city 17]
会是这样吗?
// Example model
class ESModel extends \yii\elasticsearch\ActiveRecord {
public static properties() {
'cities'
]
}
// Saving the example registry
$model = new ESModel();
$model->cities = [ 15, 17, 23, 19 ];
$model->save();
这是解决方案
// Find the registry, the below line works!
$registry = ESModel::find()->where(['IN', 'cities', 17])->one()
谢谢。