elasticsearch,Python,elasticsearch" /> elasticsearch,Python,elasticsearch" />

使用python的Elasticsearch:查询特定字段

使用python的Elasticsearch:查询特定字段,python,elasticsearch,Python,elasticsearch,我正在使用python的elasticsearch模块连接并搜索我的elasticsearch集群 在集群中,我的索引中的一个字段是“message”-我想从python中查询我的elastic,以获取此“message”字段中的特定值 下面是我的基本搜索,它只返回特定索引的所有日志 es = elasticsearch.Elasticsearch(source_cluster) doc = { 'size' : 10000, 'query': {

我正在使用python的elasticsearch模块连接并搜索我的elasticsearch集群

在集群中,我的索引中的一个字段是“message”-我想从python中查询我的elastic,以获取此“message”字段中的特定值

下面是我的基本搜索,它只返回特定索引的所有日志

    es = elasticsearch.Elasticsearch(source_cluster)
    doc = {
        'size' : 10000,
        'query': {
            'match_all' : {}
        }
    }
res = es.search(index='test-index', body=doc, scroll='1m')
我应该如何更改此查询,以便在其“消息”字段中查找包含“已移动”一词的所有结果

从Kibana执行此操作的等效查询为:

\u索引:测试索引和消息:已移动

谢谢


Noam

您需要使用
匹配查询。试试这个:

doc = {
    'size' : 10000,
    'query': {
        'match' : {
            'message': 'moved'
        }
    }
}

您可以关闭:)很高兴它有帮助!