Python,为什么Elasticsearch不根据给定的查询返回记录?

2024-09-30 18:30:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我是elasticsearch的新手,我正在尝试通过多匹配查询获取数据

以下数据示例:

{   
    .......
    "_source": {
        "itemid": 40233,
        "value": "176016",
    }
}
{   
    .......
    "_source": {
        "itemid": 40238,
        "value": "176016",
    }
}
{   
    "_index": "uint-2018-12-04",
    .......
    "_source": {
        "itemid": 40203,
        "value": "176016",
    }
}

我的代码:

def __init__(self, CustomerName, DeviceID):
    self.client = Elasticsearch(hosts=['***.***.***.***'])
    self.search = Search(using=self.client, index="ind-*").extra(size=50)

def get_data_test(self):
    self.search.query("match", itemid=40233)
    response = self.search.execute()
    for hitX in response.hits.hits:
        print(hitX)

它工作了,但没有返回预期的记录, 它返回所有记录


Tags: 数据selfclientsourcesearchindexvalueresponse