lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xdzgor1 ...@alpha-solutions.dk>
Subject no result
Date Thu, 13 Oct 2011 11:03:54 GMT
Hi, can someone please help me with the following simple example. Why does my
search not result in a hit?

Analyzer indexAnalyzer = new StandardAnalyzer(Version.LUCENE_33);
IndexWriterConfig indexWriterConfig = new
IndexWriterConfig(Version.LUCENE_33, indexAnalyzer);
Directory ramDirectory = new RAMDirectory();
IndexWriter indexWriter = new IndexWriter(ramDirectory, indexWriterConfig);
Document document = new Document();
document.add(new Field("f1", "a b", Field.Store.YES,
Field.Index.NOT_ANALYZED));
indexWriter.addDocument(document);
indexWriter.optimize();
indexWriter.close();

IndexReader indexReader = IndexReader.open(ramDirectory);
IndexSearcher indexSearcher = new IndexSearcher(indexReader);
Analyzer queryAnalyzer = new StandardAnalyzer(Version.LUCENE_33);
QueryParser queryParser = new QueryParser(Version.LUCENE_33, "id",
queryAnalyzer);
Query query = queryParser.parse("f1:a b");
TopDocs hits = indexSearcher.search(query, 100);
int count = hits.totalHits;

Thanks,
Peter


--
View this message in context: http://lucene.472066.n3.nabble.com/no-result-tp3418300p3418300.html
Sent from the Lucene - General mailing list archive at Nabble.com.

Mime
View raw message