【发布时间】:2018-01-14 08:50:41
【问题描述】:
我正在将我的 PHP MySQL 应用程序转换为 Elasticsearch, 这是我的 PHP MySQL 查询以及如何将此查询写入 Elasticseach(5.5 版)
我尝试编写聚合,但结果计数与旧 MySQL 结果计数不匹配。
SELECT COUNT(DISTINCT offerName, `OfferID`, `duration`, `price`, `numChannels`, providerName) AS "totalRecords" FROM `video` WHERE `active` = 'Y'
这是我的 Elasticsearch 查询:
{
"size": 0,
"query":
{ "bool": {
"should": [
{ "match": { "active": "Y" }}
]
}
},
"aggs": {
"count_by_OfferID": {
"terms": {
"field": "offerID"
}
},
"count_by_offerName":{
"terms": {
"field": "offerName"
}
},
"count_by_duration":{
"terms": {
"field": "duration"
}
},
"count_by_price":{
"terms": {
"field": "price"
}
},
"count_by_downloadSpeed":{
"terms": {
"field": "downloadSpeed"
}
},
"count_by_numChannels":{
"terms": {
"field": "numChannels"
}
},
"count_by_providerName":{
"terms": {
"field": "providerName"
}
}
}
}
【问题讨论】:
-
请发布您的汇总
-
你可以在这里发布你的 elasticQuery 吗?
-
我已经更新了我的 elasticsearch 查询,请检查一下,这是编写查询以在 ES 中获取不同值的方式还是有其他方式?
标签: php mysql elasticsearch