简体   繁体   English

lucene .net在哪里缓存搜索结果?

[英]Where does lucene .net cache the search results?

I'm trying to figure out where Lucene stores the cached query results, and how it's configured to do so - and how long it caches for. 我试图弄清楚Lucene将缓存的查询结果存储在何处,以及如何配置这样做-以及缓存了多长时间。

This is for an ASP.NET 3.5 solution. 这是针对ASP.NET 3.5解决方案的。

I'm getting this problem: 我遇到了这个问题:
If I run a search and sort the result by a particular product field, it seems to work the very first time each search and sort combination is used. 如果我运行搜索并按特定产品字段对结果进行排序,则似乎在第一次使用每种搜索和排序组合时都可以使用。 If I then go in and change some product attributes, reindex and run the same search and sort, I get the products returned in the same order as the very first result. 然后,如果我进入并更改一些产品属性,重新索引并运行相同的搜索和排序,我将以与第一个结果相同的顺序获得返回的产品。

example

Product A is named: foo 产品A的名称为:foo
Product B is named: bar 产品B的名称为:bar

For the first search, sort by name desc. 对于第一次搜索,请按名称desc排序。 This results in: 结果是:

  1. Product A 产品A
  2. Product B 产品B


Now mix up the data a bit: 现在稍微混合一下数据:

  1. Change names to: 将名称更改为:
    Product A named: bar 产品A的名称:bar
    Product B named: foo 产品B的名称为:foo
  2. reindex 重新索引
  3. verify that the index contains the changes for these two products. 验证索引是否包含这两个产品的更改。
  4. search 搜索

Result: 结果:

  1. Product A 产品A
  2. Product B 产品B

Since I changed the alphabetical order of the names, I expected: 由于我更改了名称的字母顺序,因此我期望:

  1. Product B 产品B
  2. Product A 产品A

So I think that Lucene is caching the search results. 因此,我认为Lucene正在缓存搜索结果。 (Which, btw, is a very good thing.) I just need to know where/how to clear these results. (其中,顺便说一句,是一件非常好的事情。)我只需要知道在哪里/如何清除这些结果。 I've tried deleting the index files and doing an IISreset to clear the memory, but it seems to have no effect. 我尝试删除索引文件并进行IISreset清除内存,但似乎没有效果。 So I'm thinking there is another set of Lucene files outside of the indexes that Lucene uses for caching. 所以我想在Lucene用于缓存的索引之外还有另一组Lucene文件。

EDIT 编辑

I just found out that you must create the index for field you wish to sort on as un-tokenized. 我刚刚发现,您必须为要排序的字段创建索引(未标记)。 I had the field as tokenized, so sorting didn't work. 我将该字段标记为令牌,因此排序无法正常进行。

Lucene.net has a simple mechanism for caching, by using QueryFilters. Lucene.net通过使用QueryFilters具有简单的缓存机制。 You need to close and and re open an IndexSearcher when a change is made to your index and you want to reflect the changes of it 当您对索引进行更改并且您想反映它的更改时,您需要关闭然后重新打开IndexSearcher

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM