How to use multifieldquery and filters in Lucene.net -
I want to search a multi field on a lucene.net index but filter out the results based on a field. Here's what I am currently doing:
There are definitions for indexing areas:
doc.Add (new field ("id", id. ToString (), field.store.Yes, field.inindex.IN_TOKENIZED); Doc.Add (new field ("title", title, field.store.no, field.index.onlygd)); Doc.Add (new field ("summary", summary, field.store.no, field.index.org, field. TermVector.YES)); Doc.Add (new field ("description", description, field.store.no, field.index.org, field. TermVector.YES)); Doc.Add (new field ("distribution", distribution, field.store.no, field.index.un_TOKENIZED));
When I search, I do the following:
Multifield skitter parser = new multifielded screener (new string [] {"title", "Summary", "description"}, analyzer); Parser.SetDefaultOperator (QueryParser.Operator.and); Query query = parser Text (text); Boolean extraction BCE = new booleanactine (); Termike tq = new termquery (new period ("distribution", distribution)); Bq.Add (tq, booleanquale oakur.UST); Filter filter = new query filter (BQ); Hit Hit = Searcher Search (query, filter);
However, the result is always 0 hits.
What am I doing?
I think I now have a solution I have abandoned the use of QueryFilter and I have a boolean Query so that the result of multifield scan is removed. The code will look something like this:
Multifield Skitter Parser = New Multifield Screws [] {"Title", "Summary", "Details"}, Analyzer); Parser.SetDefaultOperator (QueryParser.Operator.and); Query query = parser Text (text); Boolean extraction BCE = new booleanactine (); Termike tq = new termquery (new period ("distribution", distribution)); Bq.Add (tq, booleanquale oakur.UST); Bq.Add (query, boolean clove, ok. MUST) hit hit = finder Search (BQ);
Comments
Post a Comment