lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark harwood <markharw...@yahoo.co.uk>
Subject Re: How to Cache Filter Results between Servers
Date Mon, 29 Nov 2010 10:10:14 GMT
>>              1. why ir.hashCode() returns different value every time I run this 
>>code?

Presumably because it is a different object instance in a different JVM? 
IndexReader.hashCode() and IndexReader.equals() are not designed to 
represent/summarise the physical contents of an index.
They are only used to determine the same instance of a Java object e.g. so that 
cached items created from one IndexReader can recognise that the same 
IndexReader instance is still in use in the JVM when the cache is queried with a 
given reader as context.

Cheers
Mark


----- Original Message ----
From: Sariny <sariny@gmail.com>
To: java-user <java-user@lucene.apache.org>
Sent: Mon, 29 November, 2010 3:50:34
Subject: How to Cache Filter Results between Servers

hello everyone

        I have this test code:

        IndexReader ir = getReader(); 
        TermQuery q = new TermQuery(new 
Term("sub_id",NumericUtils.intToPrefixCoded(57)));
        
        Filter f = new QueryWrapperFilter(q);
        try
        {
            DocIdSet s = f.getDocIdSet(ir);

            DocIdSetIterator i = s.iterator();
            while(i.nextDoc() != DocIdSetIterator.NO_MORE_DOCS)
            {
                System.out.println(i.docID());
            }

            System.out.println(f.hashCode());
            System.out.println(s.hashCode());
            System.out.println(ir.hashCode());
            System.out.println(ir.getFieldCacheKey().hashCode());
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }


       1. getReader() returns a MultiReader may consist of  several 
IndexReaders, in my test case ,only consist of one IndexReader
       2. index files won't change 

      assuming that index files won't be updated, and my question is : 
        
      1. why ir.hashCode() returns different value every time I run this code?
      2. if I copy the index file to another server ,and they provide search 
service together,will f.getDocIdSet(ir) return the same DocIdSet? if true,how to 
cache filter results and share between the 2 servers?  how to form a cache key 
not influenced by question 1?



      Thanks ~~

                                                                                
                                                                                
              




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


      

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message