如何优化给定查询以更新弹性搜索索引中的属性?

时间:2020-04-15 12:56:29

标签: elasticsearch dsl

我在Elasticsearch中编写了以下查询,该查询基于file.filename更新属性。大约需要6秒钟。每条记录,总共590条这样的记录。我想知道是否有更好的方法来针对更大的音量进行优化。查询如下:

            $results = $e->update_by_query(
            index => $index_name,
            body  => {
                    query => {
                    match_phrase => {
                            "file.filename" => $filename
                            }
                    },
                    script => {
                            source => "ctx._source.dbattrs = params.value",
                            params => {
                                    value => {
                                    creation_datetime => $creation_dt,
                                    edi_name => $val->{edi_name},
                                    status => $val->{status},
                                    ic_number => $val->{ic_number},
                                    comment => $val->{comment},
                                    version_id => $val->{version_id},
                                    actions => $val->{actions},
                                    edi_partner => $val->{edi_partner},
                                    document_id => $val->{document_id},
                                    document_uuid => $val->{document_uuid},
                                    document_name => $val->{document_name}
                                    }
                            }
                    }
            }
    );

该索引在未来几天内可能有数百万条记录。我需要对其进行优化以减少更新过程的总体时间。

谢谢。

0 个答案:

没有答案