我尝试了以下方法来组合查询,但我不知道如何在这些查询中添加 (AND,OR,NOT) 运算符。
BooleanQuery booleanQuery = new BooleanQuery();
Query query1 = new TermQuery(new Term("Skill_Summary", "Java"));
Query pageQueryRange = NumericRangeQuery.NewIntRange("Experience", 1, 2, true, true);
booleanQuery.Add(query1, BooleanClause.Occur.MUST);
booleanQuery.Add(pageQueryRange, BooleanClause.Occur.MUST);
var hits = searcher.Search(booleanQuery);
上面的结果booleanQuery
还是+Skill_Summary:Java +Experience:[1 TO 2]
没有得到结果
String termQueryString = "Skill_Summary:\"Java\"";
Query termQuery = queryParser.Parse(termQueryString);
Query QueryRange = NumericRangeQuery.NewIntRange("Experience", 1, 3, true, true);
Query query = termQuery.Combine(new Query[] { termQuery, QueryRange });
var hits = searcher.Search(query);