本文整理汇总了C#中Lucene.Net.Search.BooleanClause类的典型用法代码示例。如果您正苦于以下问题:C# BooleanClause类的具体用法?C# BooleanClause怎么用?C# BooleanClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BooleanClause类属于Lucene.Net.Search命名空间,在下文中一共展示了BooleanClause类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNumericRangeQuery
protected void AddNumericRangeQuery(BooleanQuery query, NumericRangeField range, BooleanClause.Occur occurance)
{
var startTerm = new Term(range.FieldName, NumberTools.LongToString(range.Start));
var endTerm = new Term(range.FieldName, NumberTools.LongToString(range.End));
var rangeQuery = new RangeQuery(startTerm, endTerm, true);
query.Add(rangeQuery, occurance);
}
示例2: AddNumericRangeQuery
protected void AddNumericRangeQuery(BooleanQuery query, NumericRangeField range, BooleanClause.Occur occurance)
{
var startTerm = new Term(range.FieldName, SearchHelper.FormatNumber(range.Start));
var endTerm = new Term(range.FieldName, SearchHelper.FormatNumber(range.End));
var rangeQuery = new RangeQuery(startTerm, endTerm, true);
query.Add(rangeQuery, occurance);
}
示例3: AddDateRangeQuery
internal static void AddDateRangeQuery(BooleanQuery query, DateRangeSearchParam.DateRangeField dateRangeField, BooleanClause.Occur occurance)
{
var startDateTime = dateRangeField.StartDate;
if (dateRangeField.InclusiveStart)
{
if (startDateTime != DateTime.MinValue)
{
startDateTime.ChangeTime(0, 0, 0, 0);
}
}
var endDateTime = dateRangeField.EndDate;
if (dateRangeField.InclusiveStart)
{
if (endDateTime != DateTime.MaxValue)
{
endDateTime = endDateTime.ChangeTime(23, 59, 59, 59);
}
}
BooleanQuery.SetMaxClauseCount(int.MaxValue);
if (!(dateRangeField.StartDate == DateTime.MinValue && dateRangeField.EndDate == DateTime.MaxValue))
{
query.Add(new RangeQuery(new Term(SearchFieldIDs.CreatedDate, startDateTime.ToString("yyyyMMdd")), new Term(SearchFieldIDs.CreatedDate, endDateTime.ToString("yyyyMMdd")), true), occurance);
}
}
示例4: MergeQueries
public static Query MergeQueries(Query queryA, Query queryB, BooleanClause.Occur queryAOccurence, BooleanClause.Occur queryBOccurence)
{
BooleanQuery compoundQuery = new BooleanQuery();
compoundQuery.Add(new BooleanClause(queryA, queryAOccurence));
compoundQuery.Add(new BooleanClause(queryB, queryBOccurence));
return compoundQuery;
}
示例5: Phrase
public static PhraseQuery Phrase(this BooleanQuery inputQuery, BooleanClause.Occur occur = null)
{
BooleanQuery parentQuery = GetParentQuery(inputQuery);
PhraseQuery query = new PhraseQuery();
SetOccurValue(inputQuery, ref occur);
parentQuery.Add(query, occur);
return query;
}
示例6: Raw
public static Query Raw(this BooleanQuery booleanQuery, string field, string queryText, BooleanClause.Occur occur = null)
{
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29);
QueryParser queryParser = new QueryParser(Version.LUCENE_29, field, analyzer);
Query query = queryParser.Parse(queryText);
booleanQuery.Add(query, occur);
return query;
}
示例7: Term
public static TermQuery Term(this BooleanQuery inputQuery, string fieldName, string fieldValue, BooleanClause.Occur occur = null)
{
Term term = new Term(fieldName, fieldValue);
BooleanQuery parentQuery = GetParentQuery(inputQuery);
TermQuery query = new TermQuery(term);
SetOccurValue(inputQuery, ref occur);
parentQuery.Add(query, occur);
return query;
}
示例8: Group
public static BooleanQuery Group(this BooleanQuery inputQuery, BooleanClause.Occur occur = null, params Action<GroupedBooleanQuery>[] queries)
{
var groupedBooleanQuery = inputQuery.AddGroup(BooleanClause.Occur.SHOULD, queries);
if (groupedBooleanQuery == null)
{
throw new Exception("An error occurred creating the inner query");
}
return inputQuery.AddGroup(BooleanClause.Occur.SHOULD, queries);
}
示例9: AddQueriesToBoolean
public static void AddQueriesToBoolean(
BooleanQuery bq,
IEnumerable<Search.Query> queries,
BooleanClause.Occur occur)
{
foreach (var query in queries)
{
bq.Add(query, occur);
}
}
示例10: AssertResult
private static void AssertResult(LuceneQueryPredicateExpression result, BooleanClause.Occur expectedOccur)
{
Assert.That(result, Is.Not.Null, "Expected LuceneQueryPredicateExpression to be returned.");
Assert.That(result, Is.Not.SameAs(predicate));
Assert.That(result.QueryField, Is.SameAs(predicate.QueryField));
Assert.That(result.QueryPattern, Is.SameAs(predicate.QueryPattern));
Assert.That(result.QueryType, Is.EqualTo(predicate.QueryType));
Assert.That(result.Occur, Is.EqualTo(expectedOccur));
Assert.That(result.Boost, Is.EqualTo(predicate.Boost));
Assert.That(result.AllowSpecialCharacters, Is.EqualTo(predicate.AllowSpecialCharacters));
}
开发者ID:johnculviner,项目名称:Lucene.Net.Linq,代码行数:11,代码来源:BooleanBinaryToQueryPredicateExpressionTreeVisitorTests.cs
示例11: MakeBooleanQuery
public static Search.Query MakeBooleanQuery(
IEnumerable<Search.Query> queries,
BooleanClause.Occur occur)
{
if (queries.Count() <= 1)
{
throw new InvalidOperationException("Too few subqueries: " + queries.Count());
}
BooleanQuery bq = new BooleanQuery();
AddQueriesToBoolean(bq, queries, occur);
return bq;
}
示例12: ApplyNumericRangeSearchParam
protected BooleanQuery ApplyNumericRangeSearchParam(BooleanClause.Occur innerOccurance)
{
var innerQuery = new BooleanQuery();
if (Ranges.Count <= 0) return null;
foreach (var range in Ranges)
{
AddNumericRangeQuery(innerQuery, range, innerOccurance);
}
return innerQuery;
}
示例13: ApplyDateRangeSearchParam
protected BooleanQuery ApplyDateRangeSearchParam(BooleanClause.Occur innerCondition)
{
var innerQuery = new BooleanQuery();
if (Ranges.Count <= 0) return null;
foreach (var dateParam in Ranges)
{
AddDateRangeQuery(innerQuery, dateParam, innerCondition);
}
return innerQuery;
}
示例14: GetItems
public virtual List<SkinnyItem> GetItems(IEnumerable<SearchParam> parameters, bool showAllVersions, string sortField, bool reverse, int start, int end, out int totalResults)
{
Assert.IsNotNull(Index, "Index");
var translator = new QueryTranslator(Index);
var query = new BooleanQuery();
foreach (var parameter in parameters.Where(p => p != null))
{
var innerQueryResult = parameter.ProcessQuery(parameter.Condition, Index);
if (innerQueryResult.GetClauses().Length > 0)
{
var clause = new BooleanClause(innerQueryResult, translator.GetOccur(parameter.Condition));
query.Add(clause);
}
}
return RunQuery(query, showAllVersions, sortField, reverse, start, end, out totalResults);
}
示例15: Parse
public ISearchBuilder Parse(string[] defaultFields, string query, bool escape, bool mandatory) {
if ( defaultFields.Length == 0 ) {
throw new ArgumentException("Default field can't be empty");
}
if ( String.IsNullOrWhiteSpace(query) ) {
throw new ArgumentException("Query can't be empty");
}
if (escape) {
query = QueryParser.Escape(query);
}
var analyzer = LuceneIndexProvider.CreateAnalyzer();
foreach ( var defaultField in defaultFields ) {
var clause = new BooleanClause(new QueryParser(LuceneIndexProvider.LuceneVersion, defaultField, analyzer).Parse(query), mandatory ? BooleanClause.Occur.MUST : BooleanClause.Occur.SHOULD);
_clauses.Add(clause);
}
_query = null;
return this;
}