我是Elasticsearch的新手,希望能够提供一些有关如何提高索引性能的调优和提示。
目前索引中有大约4500个文档,光盘大小约为34GB,包含带有一些元数据的PDF。 PDF是使用Mapper Attachment插件编制索引的,每个插件数量从10MB到150MB,有些则高达250MB。
我的问题是搜索操作需要很长时间,有时长达数秒,我在最多0到7个字段上进行过滤,在2上加上一个查询字符串查询对文档文本(base64编码),title,和其他一些元字段。我还对所有结果使用分页(每页最多450页10个文档)并突出显示哪些部分被击中。我想这是我问题的一部分,但我真的无法摆脱它。
服务器有8GB的RAM,ElasticSearch的ES_HEAP_SIZE设置为2GB,我猜这是我问题的另一部分,瓶颈就在这里,对吧?不知道我可以增加多少,因为它也在运行Web服务器。服务器当然可以升级。
我没有更改默认值中有关分片的任何设置。它目前托管在Azure,但我现在不知道如果我有SSD或旋转光盘
我并不感到惊讶,但我想了解原因
我可以做些什么来改善我的表现?
根据要求,这是一个示例查询。
{
"index": "publications",
"body": {
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
[{
"range": {
"pubdate": {
"gte": "2010-01-01T00:00:00",
"lte": "2016-01-01T00:00:00"
}
}
}, {
"term": {
"author": "daniel"
}
}, {
"term": {
"title": "rock"
}
}]
]
}
},
"query": {
"query_string": {
"fields": [
["title", "author", "files.data", "articleId"]
],
"query": "Hard"
}
}
}
},
"highlight": {
"fields": {
"title": {},
"author": {},
"articleId": {},
"exact_articleId": {},
"files.data": {}
}
},
"sort": {
"date": {
"order": "desc"
},
"_score": {
"order": "desc"
}
},
"size": 10,
"from": 0,
"fields": ["id", "title", "pubdate", "orderable", "articleId", "author", "languages", "types", "exact_title", "files.file", "files.name", "bibas_date"],
"_source": ["files.file", "files.name"]
}
}
这是我的映射
{
"publications": {
"aliases": {},
"mappings": {
"publication": {
"properties": {
"articleId": {
"type": "string",
"store": true,
"analyzer": "analyzer_standard_whitespace"
},
"author": {
"type": "string",
"store": true,
"analyzer": "analyzer_standard",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"date": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
},
"created": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
},
"exact_articleId": {
"type": "string",
"store": true,
"analyzer": "analyzer_keyword"
},
"exact_title": {
"type": "string",
"store": true,
"analyzer": "analyzer_keyword"
},
"files": {
"properties": {
"data": {
"type": "attachment",
"path": "full",
"fields": {
"data": {
"type": "string",
"store": true,
"term_vector": "with_positions_offsets",
"analyzer": "analyzer_standard_whitespace"
},
"author": {
"type": "string"
},
"title": {
"type": "string"
},
"name": {
"type": "string"
},
"date": {
"type": "date",
"format": "dateOptionalTime"
},
"keywords": {
"type": "string"
},
"content_type": {
"type": "string"
},
"content_length": {
"type": "integer"
},
"language": {
"type": "string"
}
}
},
"description": {
"type": "string",
"store": true
},
"file": {
"type": "string",
"store": true,
"analyzer": "analyzer_keyword"
},
"name": {
"type": "string",
"store": true,
"analyzer": "analyzer_keyword"
}
}
},
"id": {
"type": "integer",
"store": true
},
"keywords": {
"type": "string",
"store": true,
"analyzer": "analyzer_keyword"
},
"languages": {
"type": "string",
"store": true,
"analyzer": "analyzer_keyword"
},
"orderable": {
"type": "boolean",
"store": true
},
"pubdate": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
},
"title": {
"type": "string",
"store": true,
"analyzer": "analyzer_standard",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"types": {
"type": "string",
"store": true,
"analyzer": "analyzer_keyword"
},
"updated": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
}
}
}
},
"settings": {
"index": {
"creation_date": "1451478916341",
"analysis": {
"analyzer": {
"analyzer_standard_whitespace": {
"filter": "lowercase",
"tokenizer": "whitespace"
},
"analyzer_standard": {
"filter": "lowercase",
"tokenizer": "standard"
},
"analyzer_keyword": {
"filter": "lowercase",
"tokenizer": "keyword"
}
}
},
"number_of_shards": "5",
"uuid": "PjlrtJUUT1CrGduRpxPETw",
"version": {
"created": "1070399"
},
"number_of_replicas": "1"
}
},
"warmers": {}
}
}
答案 0 :(得分:0)
尝试从_source中排除大字段(数据)。我认为这肯定会解决你的问题。