dtnpzghys01643322 2018-10-11 06:55
浏览 55

如何从Elasticsearch获取不同的记录

I am working on Elasticsearch (ES) for last couple of weeks. There are millions of records currently present in different search indices in ES.

I have noticed that in different search indices, there is duplication of records and it is creating problem.

We can search for duplicate records via code and remove those records. May be this can be applicable, but I have more than 100 million records so it will take lot of time.

My requirement is, while we fetch records from ES, we can apply different filters. Is there any filter or way we can only fetch distinct records? I am currently using REST API using PHP.

Here is the code that I am currently using and filters are working perfectly.

$params = [
    'index' => 'MyIndex',
    'type' => 'MyType',
    'from' => 0,
    'size' => 10,
    'body' => [
        'query' => [
            'bool' => [
                'must' => [
                    [ 'match' => [ 'image' => true ] ],
                    [ 'simple_query_string' => [ 'query' => 'MyQuery' ] ]
                ]
            ]
        ]
    ]
];

I also tried looking something from "Aggregations", but couldn't find something related to my requirement.

Quick help will be highly appreciated.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douli1854 2018-10-11 07:35
    关注

    I think what you are looking for is "collapsing".

    Elasticsearch supports it from 6.x:

    https://www.elastic.co/guide/en/elasticsearch/reference/6.x/search-request-collapse.html

    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题