What is the equallent operator like "IN" of SQL Server for LUCENE.NET
How can i get " IN " (of SQL Server) functionality in LUCENE.NET?
Suppose assume that some records are exist with ID : a开发者_如何学运维,b,c,d,e,f,..
So I want to get the records which are in ('a','b','c') by using Lucene.net.
Please let me know how can i write this query in Lucene.net.
Thanks in Advance.
You need to use a BooleanQuery with the SHOULD clause.
BooleanQuery query = new BooleanQuery();
query.Add(new TermQuery(new Term("ID", "a"), Occur.SHOULD));
query.Add(new TermQuery(new Term("ID", "b"), Occur.SHOULD));
query.Add(new TermQuery(new Term("ID", "c"), Occur.SHOULD));
This means that any result must have either ID = a, b, or c.
Query q = new QueryParser("ID", new YourAnalyzer()).Parse("a b c d") :)
精彩评论