[英]How does Hibernate Search (Lucene indexing) work?
I am using Hibernate Search built on top of Lucene indexing. 我正在使用基于Lucene索引构建的Hibernate Search。 If indexes are created against database table the performance will be good in returning the results. 如果针对数据库表创建索引,则返回结果的性能会很好。
My question is, once indexes are created, if we query for the results does Hibernate Search fetch results from the original database table using the created indexes? 我的问题是,一旦创建索引,如果我们查询结果,Hibernate Search会使用创建的索引从原始数据库表中获取结果吗? or does it not need to hit the database to fetch the results? 还是不需要访问数据库即可获取结果?
Thanks! 谢谢!
Unless you use Projections the indexes are used only to identify the set of primary keys matching the query, these are then used to load the entities from the Database. 除非使用Projections ,否则索引仅用于标识与查询匹配的主键集,然后将这些索引用于从数据库中加载实体。
There are many good reasons for this: 这样做有很多充分的理由:
That said, if you don't need fully managed entities you can use Projections to load the fields you annotated as Stored.YES. 就是说,如果不需要完全托管的实体,则可以使用Projections加载标注为Stored.YES的字段。 A common pattern is to provide preview of matches using projections, and then when the user clicks for details to load the full entity matching that result. 一种常见的模式是使用投影提供匹配的预览,然后在用户单击以获取详细信息以加载与该结果匹配的完整实体时提供预览。
By default, every time an object is inserted, updated or deleted through Hibernate, Hibernate Search updates the according Lucene index as per documentation 默认情况下,每次通过Hibernate插入,更新或删除对象时,Hibernate Search都会根据文档更新相应的Lucene索引
Hence, the further searches will yeild the data through lucene indexes only. 因此,进一步的搜索将仅通过Lucene索引获得数据。
Another Question explaining how Indexes work 另一个解释索引如何工作的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.