【发布时间】:2016-01-06 00:10:37
【问题描述】:
我有数据存储在这样的弹性索引中
{'name': 'Arnie Metz PhD', 'user_id': 'CL_000960', 'email_id': 'streich.anjelica@gmail.com', 'customer_id': 'CL_2135514566_1427476813'}
{'name': 'Ms. Princess Bernhard', 'user_id': 'CL_000972', 'email_id': 'obatz@yahoo.com', 'customer_id': 'CL_2135514566_1427476810'}
{'name': "Lori O'Kon", 'user_id': 'CL_000980', 'email_id': 'murl86@schmidt.com', 'customer_id': 'CL_2135514566_1427476811'}
{'name': "Ahmad O'Reilly", 'user_id': 'CL_000981', 'email_id': 'kassie95@yahoo.com', 'customer_id': 'CL_2135514566_1427476815'}
{'name': 'Lovell Connelly', 'user_id': 'CL_000982', 'email_id': 'wweimann@mclaughlincorwin.com', 'customer_id': 'CL_2135514566_1427476815'}
{'name': 'Errol Feest', 'user_id': 'CL_000989', 'email_id': 'cordella30@yahoo.com', 'customer_id': 'CL_2135514566_1427476810'}
{'name': "May O'Conner", 'user_id': 'CL_000990', 'email_id': 'iverson51@gmail.com', 'customer_id': 'CL_2135514566_1427476815'}
{'name': 'Virgie Wyman', 'user_id': 'CL_000999', 'email_id': 'florine.jenkins@yahoo.com', 'customer_id': 'CL_2135514566_1427476812'}
{'name': 'Ofelia McClure', 'user_id': 'CL_0001001', 'email_id': 'fidelia.hilll@mayert.com', 'customer_id': 'CL_2135514566_1427476814'}
{'name': 'Mr. Edson Rosenbaum Jr.', 'user_id': 'CL_0001003', 'email_id': 'mkerluke@hotmail.com', 'customer_id': 'CL_2135514566_1427476810'}
我想从查询中得到的是使用以下查询的 user_ids 列表中的电子邮件 ID 列表
查询 1
{
"query" : {
"filtered" : {
"filter" : {
"terms" : {
"user_id" : ["CL_0004430", "CL_0004496"]
}
}
}
}
}
这没有给出结果。它给出了空结果
查询 2
{
"query": {
"bool": {
"must": [
{
"match": {
"user_id": {
"query": "['CL_00078','CL_00028']",
"operator": "or"
}
}
}
]
}
},
"aggs": {}
}
这按预期工作,但问题在于条件参数的限制。我不能在列表中提供超过 1000 封电子邮件。
有没有更好的查询方法来获得超过 10000 条记录?
【问题讨论】:
-
也许我错了。问题是制作超过 10000 封电子邮件的过滤器或将它们放入结果中?
-
也许您的查询 1 可以使用小写字母 (CL_0004430 => cl_0004430)。
terms是严格的比较,你的映射可能是这个字段的小写(它是默认解析器完成的)。match不区分大小写
标签: elasticsearch