我有一个带有2.7M文档的索引。这是我的疑问:
GET ad_index/ad_type/_search
{
"size": 20,
"sort": {
"until": "desc"
},
"query": {
"bool": {
"filter": [
{
"term": {
"state": 2
}
},
{
"range": {
"until": {
"gte": "now"
}
}
}
]
}
},
"aggs" : {
"categories": {
"terms": {
"field": "category_id",
"size": 2000
}
}
}
}此查询没有匹配子查询。我有一个节点,一个碎片和零个副本。
查询时间- 60 ms。没有聚合- 40毫秒。击中~ 50000。
可以吗还是可以更快些?我要10毫秒。我用MySQL可以得到<10毫秒。
我用ES 2.4。索引大小1.34GB。我对分数不感兴趣。
UPD。
我的地图:
{
"ad_index": {
"mappings": {
"ad_type": {
"properties": {
"customer_id": {
"type": "long"
},
"deleted": {
"type": "long"
},
"dynamic_fields": {
"properties": {
"-icq-3": {
"type": "string"
},
"phone-3": {
"type": "string"
}
"email-3": {
"type": "string"
}
//and 100 more sparse dynamic fields
},
"id": {
"type": "long"
},
"category_id": {
"type": "long"
},
"until": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"state": {
"type": "long"
},
"text": {
"type": "string"
}
}
}
}
}
}其他查询:
GET ad_index/ad_type/_search
{
"size": 20,
"sort": {
"until": "desc"
},
"query": {
"bool": {
"filter": [
{
"term": {
"state": 2
}
},
{
"range": {
"until": {
"gte": "now"
}
}
},
{
"terms": {
"category_id" : [1029, 121, ... here can be more than 200 values]
}
}
]
}
},
"aggs" : {
"categories": {
"terms": {
"field": "category_id",
"size": 2000
}
}
}
}
GET ad_index/ad_type/_search
{
"size": 20,
"sort": {
"until": "desc"
},
"query": {
"bool": {
"must": [
{
"match": {
"_all": "some text"
}
}
],
"filter": [
{
"term": {
"state": 2
}
},
{
"range": {
"until": {
"gte": "now"
}
}
},
{
"terms": {
"category_id" : [1029, 121, ... here can be more than 200 values]
}
}
]
}
},
"aggs" : {
"categories": {
"terms": {
"field": "category_id",
"size": 2000
}
}
}
}发布于 2016-11-10 00:54:33
这有点慢,因为您使用的是简单的查询。
https://stackoverflow.com/questions/40502434
复制相似问题