Something new to me, I have previously enabled Lucene search using pure text fields, but stumbled recently when trying to search using a Long field:
IndexWriterConfig indexConfig = new IndexWriterConfig(Version.LUCENE_30, new StandardAnalyzer(Version.LUCENE_30));
IndexWriter indexWriter = new IndexWriter(directory, indexConfig );
Document doc = new Document();
doc.add(new NumericField("id", Store.YES, true).setLongValue(123L));
and to search on this field:
IndexSearcher is = new IndexSearcher(dir);
Query query = new TermQuery(new Term("id", NumericUtils.longToPrefixCoded(123L)));
TopDocs hits = is.search(query, 10);
No comments:
Post a Comment