首页 \ 问答 \ Elasticsearch慢速聚合(Elasticsearch Slow terms aggregation)

Elasticsearch慢速聚合(Elasticsearch Slow terms aggregation)

我有一个ES查询和聚合的问题。 在添加术语聚合之前,所有es记录数大约为1亿个,我的查询速度很快,只需要75ms,所有命中数都是105.但是在添加聚合后,如下所示:

{
    "query": {
        ...
    },
    "aggs": {
        "index": {
            "terms": {
                "field": "index"
            }
         }
     }
}

这个查询将花费20秒! 我的问题是:我的查询结果数只有105,为什么聚合太慢? 谢谢你的回复!


I hava a problem with es query and aggregation. All es record count is about 0.1 billion, before adding a terms aggregation, my query is fast, only cost 75ms and all hit count is 105. But after adding a aggregation, like this one:

{
    "query": {
        ...
    },
    "aggs": {
        "index": {
            "terms": {
                "field": "index"
            }
         }
     }
}

this query will cost 20 second! My question is: my query result count is only 105, why the aggregation is so slow? Thanks for any reply!


原文:https://stackoverflow.com/questions/50893653
更新时间:2023-10-28 14:10

最满意答案

对于任何此类NLP任务,您应该使用单词嵌入,例如Word2Vec。 每个单词将表示为向量。 您的输入将是原始错误顺序的这些向量的矩阵。 您的输出将是正确顺序的这些向量的矩阵。 下面,我已经包含了一个Fast.ai课程的链接,该课程进一步讨论了单词嵌入。

https://course.fast.ai/lessons/lesson6.html

*请注意,基于问题公式,我假设你的RNN能够处理输入/输出句子对。 如果情况并非如此,或者您遇到问题,请发表评论,我可以给您更多想法。


For any NLP task such as this you should be using word embeddings, e.g. Word2Vec. Each word will be represented as a vector. Your input will be a matrix of these vectors in the original, incorrect order. Your output will be a matrix of these vectors in the correct order. Below, I've included a link to a Fast.ai course that further discusses word embeddings.

https://course.fast.ai/lessons/lesson6.html

*Note that based on the problem formulation, I'm assuming your RNN is capable of handling input / output sentence pairs. If that's not the case or you run into problems along those lines, leave a comment and I can give you some more ideas.

相关问答

更多
  • 第二个有效地与第一个循环相同,返回循环和最终状态中收集的所有输出的列表。 它通过一些安全检查可以提高效率。 它还支持有用的功能,如可变序列长度。 Tensorflow教程中提供了第一个选项,以便您了解如何解开RNN,但第二个选项是“生产”代码的首选。 The second effectively does the same as the loop in the first, returning a list of all the outputs collected in the loop and the f ...
  • 从keras文档中 , categorical_crossentropy只是多类logloss。 这里记录日志丢失的数学和理论解释。 基本上,LSTM将标签分配给单词(或字符,具体取决于您的模型),并通过惩罚单词(或字符)序列中的错误标签来优化模型。 该模型采用输入字或字符向量,并尝试根据训练示例猜测下一个“最佳”字。 分类交叉熵是衡量猜测有多好的定量方法。 当模型迭代训练集时,它会在猜测下一个最佳单词(或字符)时减少错误。 From the keras documentation, categorical ...
  • 我意识到问题是什么。 我试图使用Tensorflow会话(模型拟合后)而不是直接通过Keras方法提取模型权重。 这导致权重矩阵完全有意义(尺寸明智)但包含初始化步骤的值。 model.fit(X_train, y_train, batch_size=batch_size, nb_epoch=epochs, validation_split=0.05, callbacks=callbacks_list) p ...
  • 你对LSTM应该返回的解释是不正确的。 输出维度不需要与输入维度相匹配。 具体来说, keras.layers.LSTM的第一个参数对应于输出空间的维度,并将其设置为1。 换句话说,设置: model.add(LSTM(k, input_shape=(3,4), return_sequences=True)) 将导致(None, 3, k)输出形状。 Your interpretation of what the LSTM should return is not right. The output dim ...
  • 展开仅针对培训进行定义。 在评估期间,没有展开这样的东西,您只需输入数据并保持隐藏状态。 但是,对于培训来说,它会产生巨大的影响。 为了更好地理解这一点,让我们看看下面的图表,展开3。 UPDATE | v LSTM_t-LSTM_t+1-LSTM_t+2 LSTM_t+3-LSTM_t+4-LSTM_t+5 .... | | ...
  • 对于任何此类NLP任务,您应该使用单词嵌入,例如Word2Vec。 每个单词将表示为向量。 您的输入将是原始错误顺序的这些向量的矩阵。 您的输出将是正确顺序的这些向量的矩阵。 下面,我已经包含了一个Fast.ai课程的链接,该课程进一步讨论了单词嵌入。 https://course.fast.ai/lessons/lesson6.html *请注意,基于问题公式,我假设你的RNN能够处理输入/输出句子对。 如果情况并非如此,或者您遇到问题,请发表评论,我可以给您更多想法。 For any NLP task ...
  • 要获取所有输出的列表,您可以执行以下操作: return [tf.matmul(output, _weights['out']) + _biases['out'] for output in outputs] 这将返回一个TensorFlow张量的python数组,每个输出一个。 如果您想要一个连接所有输出的张量,请将此数组传递给tf.concat : transformed_outputs = [tf.matmul(output, _weights['out']) + _biases['out'] fo ...
  • 我认为你可以在构建训练集时处理这种情况,至少如果最后一个值(在输入序列中)和预测值之间的时间延迟是固定的。 设X_train具有维度:(nb_samples,timesteps,input_dim)和y_train具有维度(n_samples,output_dim)。 设x是一个训练输入样本。 它对应于具有维度的多变量时间序列(timesteps,input_dim)。 它的相应输出是y和维度(output_dim)。 在y中,您将值预测为可以在x中的最后一个值之后3天,LSTM“应该”掌握时间依赖性。 因 ...
  • 我不知道你指的那篇论文。 但是这里有一个关于如何在TensorFlow中实现这样的东西的想法: 您可以创建2个LSTMCell 。 如果你想支持每个单词的可变数量的字符和每个序列的可变数量的单词,你可以复制和调整dynamic_rnn的代码(参见rnn.py)而不是单个while循环,你将创建一个嵌套的while循环。 内部操作字符调用第一个LSTMCell并重置每个单词后的状态。 外部操作嵌入字(内部循环的输出)并调用第二个LSTMCell。 通常,您是否应该单独训练嵌入取决于您可用的数据量。 如果您没有 ...
  • 问题不在于合并层。 您需要创建两个嵌入层以提供2个不同的输入。 以下修改应该有效: embedding_layer_1 = Embedding(len(word_index) + 1, EMBEDDING_DIM, weights=[embedding_matrix], input_length=50, ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。