【发布时间】:2020-02-04 23:54:37
【问题描述】:
我有一个 codeigniter 应用程序,我尝试在其中设置 elasticsearch,我的 json 如下所示:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "features",
"_type": "liste",
"_id": "test",
"_score": 1.0,
"_source": {
"mnuActiveSection": "securite.features",
"rowsFeatures": [
{
"id": "50",
"idCategory": "5",
"Name": "01- Data",
"FeatureCategory": "Serie",
"NombrePrivileges": "9",
"ListePrivileges": "Admin"
},
{
"id": "51",
"idCategory": "5",
"Name": "02- Data 2",
"FeatureCategory": "Documentary",
"NombrePrivileges": "3",
"ListePrivileges": "Direction"
},
{
"id": "52",
"idCategory": "5",
"Name": "03- Data 3",
"FeatureCategory": "Films",
"NombrePrivileges": "7",
"ListePrivileges": "Super Admin"
}
]
}
}
]
}
}
我想在我的视图中显示功能列表,并通过弹性搜索来搜索文档。不幸的是我无法显示数据 json。
这不是我想要的,因为我的印象是我将所有数据分组在一个对象数组中。 为了完成,我尝试使用“foreach”,但不幸的是我没有得到我想要的东西。我被困在这个阶段。 我希望我的表中的每个数据都具有不同的 _id,例如以更好地可视化它们。
public function liste()
{
$data["mnuActiveSection"] = "securite.features";
$Finder = new FeaturesFinder();
$data["rowsFeatures"] = $Finder->FindAll();
$this->load->library('elasticsearch');
foreach($data["rowsFeatures"] as $d){
$this->elasticsearch->index = 'features';
$this->elasticsearch->create();
$this->elasticsearch->add($type ='liste',$id = 'test',$data);
var_dump($d);
}
}
如果有人可以帮我找到我感兴趣的曲目。
非常感谢
【问题讨论】:
-
澄清一下,您到底想在这里做什么?您的程序的预期输出是什么?
-
预期的结果是能够在我的视图中显示特征列表,并通过弹性搜索来搜索文档。不幸的是我无法显示数据 json
标签: php json codeigniter elasticsearch