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.

Était-ce utile?

La 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( "*" );
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top