【发布时间】:2016-05-19 21:36:21
【问题描述】:
我运行 solr 查询,它返回作业的结果集。
有些职位是重复的(但来源不同),这取决于职位名称、描述和位置是否相同。
我想遍历我的结果集,并将任何重复的内容合并到一个作业中,而该作业有多个来源...类似于:
原始结果:
$jobs = array(
array(
'id' => 'job1',
'title' => 'test',
'description' => 'test',
'location' => 'test',
'source' => 'source1',
),
array(
'id' => 'job2',
'title' => 'test',
'description' => 'test',
'location' => 'test',
'source' => 'source2',
),
array(
'id' => 'job3',
'title' => 'test',
'description' => 'test',
'location' => 'test',
'source' => 'source3',
),
array(
'id' => 'job4',
'title' => 'testing',
'description' => 'testing',
'location' => 'testing',
'source' => 'source1',
)
);
会变成:
$jobs = array(
array(
'id' => 'job1',
'title' => 'test',
'description' => 'test',
'location' => 'test',
'source' => 'source1',
'other_sources' => array(
array(
'id' => 'job2',
'title' => 'test',
'description' => 'test',
'location' => 'test',
'source' => 'source2'
),
array(
'id' => job3,
'title' => 'test',
'description' => 'test',
'location' => 'test',
'source' => 'source3'
),
),
),
array(
'id' => 'job4',
'title' => 'testing',
'description' => 'testing',
'location' => 'testing',
'source' => 'source1'
)
);
我怎样才能做到这一点?在 PHP 中或者在 Solr 查询本身中(我正在使用 Solarium 进行 Solr 查询)
【问题讨论】:
标签: php solr duplicates