lucene (2.9--- 3.6) 范围搜索优化
2012-07-25 11:23
316 查看
原先在处理范围搜索的时候,发现了SortField.BYTE 但是在建索引的时候NumericField并没有setByteValue,只有(int/ long / folat /double),很是奇怪;
逛了一些论坛,也没见啥好的解释;后来看到了
的解释,很有意思,
http://lucene.apache.org/core/old_versioned_docs/versions/2_9_0/api/all/org/apache/lucene/util/NumericUtils.html#doubleToSortableLong%28double%29
This is a helper class to generate prefix-encoded representations for numerical values and supplies converters to represent float/double values as sortable integers/longs.
To quickly execute range queries in Apache Lucene, a range is divided recursively into multiple intervals for searching: The center of the range is searched only with the lowest possible precision in the trie, while the boundaries are matched more exactly.
This reduces the number of terms dramatically.
首先解释下prefix-encoded ,前缀编码,解释下,网上看到的解释,见下
前缀码:给定一个序列的集合,若不存在一个序列是另一个序列的前缀,则该序列集合称为前缀码。
那么我可以理解为范围查找使用prefix-encoded是提高性能的一种办法;
范围搜索使用方式
但是回到文章开始SortField.BYTE到底在哪里使用,现在还是无解,有知道的可以告诉我下,谢谢。
逛了一些论坛,也没见啥好的解释;后来看到了
NumericUtils
的解释,很有意思,
http://lucene.apache.org/core/old_versioned_docs/versions/2_9_0/api/all/org/apache/lucene/util/NumericUtils.html#doubleToSortableLong%28double%29
public final class NumericUtilsextends Object
This is a helper class to generate prefix-encoded representations for numerical values and supplies converters to represent float/double values as sortable integers/longs.
To quickly execute range queries in Apache Lucene, a range is divided recursively into multiple intervals for searching: The center of the range is searched only with the lowest possible precision in the trie, while the boundaries are matched more exactly.
This reduces the number of terms dramatically.
首先解释下prefix-encoded ,前缀编码,解释下,网上看到的解释,见下
A{1。01。000。001} B{1。01。011。010} C{0。10。110。11} D{0。1。00。11}
选A B中01是011和010的前缀 C中11是110的前缀 D中1是11的前缀,0是00的前缀
前缀码:给定一个序列的集合,若不存在一个序列是另一个序列的前缀,则该序列集合称为前缀码。
那么我可以理解为范围查找使用prefix-encoded是提高性能的一种办法;
范围搜索使用方式
TermRangeQuery query =new TermRangeQuery("size",NumericUtils.longToPrefixCoded(100),NumericUtils.longToPrefixCoded(500)
但是回到文章开始SortField.BYTE到底在哪里使用,现在还是无解,有知道的可以告诉我下,谢谢。
相关文章推荐
- Lucene.Net 优化索引生成,即搜索显示优化
- 如何提高和优化Lucene搜索速度
- lucene 范围搜索表达式(range expression)
- 用lucene3.6搜索数据库和txt文件内容
- 如何在Lucene里面进行数字范围搜索 (Numeric Range Query)
- 盘古分词在 Lucene.net 2.9 版本下搜索没有结果的原因分析及盘古分词2.0版本要开发的新功能
- lucene-查询query->RangeQuery在某一范围内搜索
- BSOJ 3022 又一类数字三角形--根据数据范围的优化+背包思想递推/搜索
- Lucene范围搜索的6种实现方式
- unity战棋类游戏移动范围搜索算法设计(未优化)
- Lucene搜索范围
- 【Lucene】安全过滤器,限制搜索范围(一)
- lucene实现 在某一范围进行搜索 RangeQuery
- Lucene的数字范围搜索 (Numeric Range Query)原理
- Lucene的数字范围搜索 (Numeric Range Query)原理
- 第61天(就业班) Lucene索引库优化、内置分词器、IK分词器、关键字高亮、单字段和多字段搜索、easyui入门
- Lucene中的范围搜索
- lucene 搜索优化,个人实战经验总结
- lucene3.6笔记添加搜索功能
- 全文搜索Lucene.Net优化