[英]very slow highlight performance in lucene
當搜索頻繁的術語時,Lucene(4.6)熒光筆的性能非常慢。 搜索速度很快(100毫秒),但突出顯示可能需要一個多小時(!)。
細節:使用了很棒的文本語料庫(1.5GB純文本)。 性能不依賴於文本是否被分成更小的部分。 (也測試了500MB和5MB的部分。)存儲位置和偏移。 如果搜索非常頻繁的術語或模式,TopDocs被快速檢索(100ms),但每個“searcher.doc(id)”調用都很昂貴(5-50s),而getBestFragments()非常昂貴(超過1小時) 。 即使它們也是為此目的而存儲和索引的。 (硬件:核心i7,8GM內存)
更大的背景 :它將用於語言分析研究。 使用了一種特殊的詞干:它也存儲了詞性信息。 例如,如果搜索“adj adj adj adj noun” ,它將在文本中出現所有出現的上下文。
我可以調整其性能,還是應該選擇其他工具?
二手代碼:
//indexing
FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
offsetsType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
offsetsType.setStored(true);
offsetsType.setIndexed(true);
offsetsType.setStoreTermVectors(true);
offsetsType.setStoreTermVectorOffsets(true);
offsetsType.setStoreTermVectorPositions(true);
offsetsType.setStoreTermVectorPayloads(true);
doc.add(new Field("content", fileContent, offsetsType));
//quering
TopDocs results = searcher.search(query, limitStart+limit);
int endPos = Math.min(results.scoreDocs.length, limitStart+limit);
int startPos = Math.min(results.scoreDocs.length, limitStart);
for (int i = startPos; i < endPos; i++) {
int id = results.scoreDocs[i].doc;
// bottleneck #1 (5-50s):
Document doc = searcher.doc(id);
FastVectorHighlighter h = new FastVectorHighlighter();
// bottleneck #2 (more than 1 hour):
String[] hs = h.getBestFragments(h.getFieldQuery(query), m, id, "content", contextSize, 10000);
相關(未答復)問題: https : //stackoverflow.com/questions/19416804/very-slow-solr-performance-when-highlighting
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.