Question

I am using lucene in my project and I got to one issue, that I need to find documents which contain fields with specific name. I was only able to find solutions where you creating search term containing pairs name,value like this:

IndexSearcher searcher = new IndexSearcher(directoryReader);
TermQuery query = new TermQuery(new Term("name", "value"));
TopDocs topdocs = searcher.query(query, numberToReturn);

but as I stated, I need to find documents only by provided name of field and obtain access to value of field specified by name in selected documents.

Although I am working with Lucene.NET I will be thankfull for solution in any language.

Thank you in advance.

Was it helpful?

Solution

I find out this solution and little change made it:

 var queryParser = new QueryParser(Version.LUCENE_30, "content", analyzer);
 queryParser.AllowLeadingWildcard = true;
 var query = queryParser.Parse( "*" );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top