Where does lucene .net cache the search results?

Posted by Lanceomagnifico on Stack Overflow See other posts from Stack Overflow or by Lanceomagnifico
Published on 2009-03-27T15:53:32Z Indexed on 2010/03/21 12:01 UTC
Read the original article Hit count: 717

Filed under:
|
|

Hi,
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.

This is for an ASP.NET 3.5 solution.

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
Product B is named: bar

For the first search, sort by name desc. This results in:

  1. Product A
  2. Product B


Now mix up the data a bit:

  1. Change names to:
    Product A named: bar
    Product B named: foo
  2. reindex
  3. verify that the index contains the changes for these two products.
  4. search

Result:

  1. Product A
  2. Product B

Since I changed the alphabetical order of the names, I expected:

  1. Product B
  2. Product A

So I think that Lucene is caching the search results. (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. So I'm thinking there is another set of Lucene files outside of the indexes that Lucene uses for caching.

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.

© Stack Overflow or respective owner

Related posts about lucene.net

Related posts about ASP.NET