lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sascha Janz" <Sascha.J...@gmx.net>
Subject Aw: FieldCacheRangeFilter on docvalue field
Date Mon, 01 Feb 2016 13:58:02 GMT


i wrote a simple test...it does work
 
IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_46,
new StandardAnalyzer(Version.LUCENE_CURRENT));
iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);anden
Directory index = new RAMDirectory();
writer = new IndexWriter(index, iwc);
Document doc = new Document();
doc.add(new TextField("text","erstes Dokument",Store.YES));
doc.add(new NumericDocValuesField("id",1l));
writer.addDocument(doc);
doc = new Document();
doc.add(new TextField("text","zweites Dokument",Store.YES));
doc.add(new NumericDocValuesField("id",2l));
writer.addDocument(doc);
doc = new Document();
doc.add(new TextField("text","drittes Dokument",Store.YES));
doc.add(new NumericDocValuesField("id",3l));
writer.addDocument(doc);
doc = new Document();
doc.add(new TextField("text","viertes Dokument",Store.YES));
doc.add(new NumericDocValuesField("id",4l));
writer.addDocument(doc);
doc = new Document();
doc.add(new TextField("text","fünftes Dokument",Store.YES));
doc.add(new NumericDocValuesField("id",5l));
writer.addDocument(doc);
writer.commit();
reader = DirectoryReader.open(index);
IndexSearcher searcher = new IndexSearcher(reader);
QueryParser parser = new QueryParser(Version.LUCENE_CURRENT,"text",new StandardAnalyzer(Version.LUCENE_CURRENT));
Query q = parser.parse("Dokument");
TopDocs docs = searcher.search(q,100);
System.out.println("anzahl treffer = 5 ? " + docs.scoreDocs.length);
 
FieldCacheRangeFilter<Long> ffilter = FieldCacheRangeFilter.newLongRange("id", 1L, 3l,
true , true);
 
FilteredQuery fq3=new FilteredQuery(q,ffilter);
docs = searcher.search(fq3,100);
System.out.println("anzahl treffer = 3 ? " + docs.totalHits);

 

Gesendet: Montag, 01. Februar 2016 um 13:02 Uhr
Von: "Sascha Janz" <Sascha.Janz@gmx.net>
An: java-user@lucene.apache.org
Betreff: FieldCacheRangeFilter on docvalue field
Hi,
 
iam using lucene 4.6.0.
 
can i use a FieldCacheRangeFilter on a docvalue field?
 
like
 
FieldCacheRangeFilter<Long> ffilter = FieldCacheRangeFilter.newLongRange("dv_id", 0L,
Long.MAX_VALUE, true , true);

where dv_id is s NumericDocValue

regards
Sascha

---------------------------------------------------------------------
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