Hi i am kevin from Chile and i am new whit Lucene, I have 5 documents. Each document has a field date but i would search on range date whit TermRangeQuery . Total structure is looking like this:
public static void main(String[] args) throws IOException, ParseException { StandardAnalyzer analyzer = new StandardAnalyzer(); Directory index = new RAMDirectory(); IndexWriterConfig config = new IndexWriterConfig(analyzer); IndexWriter w = new IndexWriter(index, config); addDoc(w, "Lucene in Action", "1999-08-12"); addDoc(w, "Lucene for Dummies", "1998-08-12"); addDoc(w, "Lucene for chile", "2011-08-12"); addDoc(w, "Managing Gigabytes", "1995-08-12"); addDoc(w, "The Art of Computer Science", "2001-08-12"); w.close(); BytesRef lowerDate = new BytesRef("2015-08-13"); BytesRef upperDate = new BytesRef("1998-08-12"); TermRangeQuery query = new TermRangeQuery("isbn", lowerDate, upperDate, true, true); // 3. search IndexReader reader = DirectoryReader.open(index); IndexSearcher searcher = new IndexSearcher(reader); ScoreDoc[] hits = searcher.search(query, 100).scoreDocs; for(int i=0;i<hits.length;++i) { int docId = hits[i].doc; Document d = searcher.doc(docId); System.out.println((i + 1) + ". " + d.get("date") + "\t" + d.get("title")); reader.close(); } private static void addDoc(IndexWriter w, String title, String date) throws IOException { Document doc = new Document(); doc.add(new TextField("title", title, Field.Store.YES)); doc.add(new StringField("date", isbn, Field.Store.YES)); w.addDocument(doc); } why can i have not result the result for hits.length() is null could anyone help me please.. and sorry for my English thankĀ” -- View this message in context: http://lucene.472066.n3.nabble.com/TermRangeQuery-work-not-tp4246519.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org