The javadocs for NumericField (lucene 2.9.4) state:

You may add the same field name as a NumericField to the same document
more than once. Range querying and filtering will be the logical OR of
all values; so a range query will hit all documents that have at least
one value in the range

Furthermore, the precisionStep is defined only in terms of performance
and disk space, not in terms of affecting the results.

However, the unit test below shows that the precisionStep directly
affects the results when using multi-value fields:

Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29);
RAMDirectory directory = new RAMDirectory();
IndexWriter writer = new IndexWriter(directory, analyzer, true,
IndexWriter.MaxFieldLength.UNLIMITED);
Document document = new Document();
document.add(new NumericField("number", 4, Field.Store.YES,
true).setLongValue(480));
document.add(new NumericField("number", 4, Field.Store.YES,
true).setLongValue(180));
writer.addDocument(document);
IndexSearcher searcher = new IndexSearcher(directory, true);
Query q = new FilteredQuery(new MatchAllDocsQuery(),
NumericRangeFilter.newLongRange("number", 444l, 10000l, true, true));
TopDocs docs = searcher.search(q, null, 10);
Assert.assertEquals(1, docs.totalHits);

analyzer = new StandardAnalyzer(Version.LUCENE_29);
directory = new RAMDirectory();
writer = new IndexWriter(directory, analyzer, true,
IndexWriter.MaxFieldLength.UNLIMITED);
document = new Document();
document.add(new NumericField("number", 6, Field.Store.YES,
true).setLongValue(480));
document.add(new NumericField("number", 6, Field.Store.YES,
true).setLongValue(180));
writer.addDocument(document);
searcher = new IndexSearcher(directory, true);
q = new FilteredQuery(new MatchAllDocsQuery(),
NumericRangeFilter.newLongRange("number", 444l, 10000l, true, true));
docs = searcher.search(q, null, 10);
Assert.assertEquals(1, docs.totalHits); // fails, due to increased
precision Step

Any help would be greatly appreciated

Greg

Please consider the environment before printing this email.

This message should be regarded as confidential. If you have received this 
email in error please notify the sender and destroy it immediately.

Statements of intent shall only become binding when confirmed in hard copy by 
an authorised signatory.  The contents of this email may relate to dealings 
with other companies under the control of Detica Limited, details of which can 
be found at http://www.detica.com/statutory-information.

Detica Limited is registered in England under No: 1337451.
Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.

Reply via email to