lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Moray McConnachie (JIRA)" <>
Subject [jira] Created: (LUCENENET-338) Serialized queries function unreliably
Date Thu, 28 Jan 2010 11:11:34 GMT
Serialized queries function unreliably

                 Key: LUCENENET-338
             Project: Lucene.Net
          Issue Type: Bug
         Environment: Current trunk, standard .NET environment, Visual Studio 2008.
            Reporter: Moray McConnachie

I've just tried slotting in current trunk in place of 2.3.1 we were using previously. Everything
appears to compile and work OK, but the results are not correct when we introduce query serialization.

Executing a simple BooleanQuery: +titling:Russia 

Results returned from query when not serialised: 3878 (correct)

Results returned when query serialised deserialized and run with same Searcher: 3879

Results returned when query serialised deserialized and run with new Searcher: 3 (!)

Last time we had an issue with serialized queries and filed a bug report (,
it was an issue with the serialization of Parameter on which Occur depends, but Parameter
looks still to have the patch in as far as I can tell. 
*Test code*

string IndexPath=@"C:\SourceSafeWork\OxanOxweb\LuceneAndSearch\TEST\LuceneIndexWithFullTextSince2004";
//setup first query

BooleanQuery lucQuery = new BooleanQuery();
lucQuery.Add(new BooleanClause(new TermQuery(new Lucene.Net.Index.Term("titling","russia")),BooleanClause.Occur.MUST));

//serialize and deserialize
BinaryFormatter bf = new BinaryFormatter();
System.IO.MemoryStream ms = new System.IO.MemoryStream();
bf.Serialize(ms, lucQuery);
ms.Seek(0, System.IO.SeekOrigin.Begin);
Query lucQuery2 = (Query)bf.Deserialize(ms);

//get hit counts for 2 searches

IndexSearcher searcher = new IndexSearcher();
int hitCount = searcher.Search(lucQuery, 20).totalHits;  //3878 hits

 //bizarrely if I do not close the searcher and reopen the hit count is only 1 different i.e.
searcher = new IndexSearcher(@IndexPath);

int hitCount2 = searcher.Search(lucQuery2, 20).totalHits; //3 hits

if (hitCount != hitCount2)
    MessageBox.Show("Error in serialisation - different hit count");

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message