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

时间:2018-12-11 11:17:15

标签: python elasticsearch elasticsearch-dsl

我是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)

它有效,但不返回预期的记录, 它返回所有记录

1 个答案:

答案 0 :(得分:0)

AccountNumber方法返回Code = 33968对象的副本。您需要这样做:

12/12/2018