当前位置: 首页>>代码示例>>C#>>正文


C# Search.BooleanClause类代码示例

本文整理汇总了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);
 }
开发者ID:katebutenko,项目名称:SitecoreSearchContrib,代码行数:7,代码来源:NumericRangeSearchParam.cs

示例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);
 }
开发者ID:mebinum,项目名称:AdvanceDb,代码行数:7,代码来源:NumericRangeSearchParam.cs

示例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);
            }
        }
开发者ID:udt1106,项目名称:Sitecore-Item-Buckets,代码行数:27,代码来源:SearcherMethods.cs

示例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;
		}
开发者ID:aqueduct,项目名称:Aqueduct.SitecoreLib,代码行数:8,代码来源:QueryHelper.cs

示例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;
 }
开发者ID:Code-Miners,项目名称:Lucinq,代码行数:8,代码来源:BooleanQueryExtensions.cs

示例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;
 }
开发者ID:Code-Miners,项目名称:Lucinq,代码行数:8,代码来源:BooleanQueryExtensions.cs

示例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;
 }
开发者ID:Code-Miners,项目名称:Lucinq,代码行数:9,代码来源:BooleanQueryExtensions.cs

示例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);
 }
开发者ID:Code-Miners,项目名称:Lucinq,代码行数:9,代码来源:BooleanQueryExtensions.cs

示例9: AddQueriesToBoolean

 public static void AddQueriesToBoolean(
     BooleanQuery bq,
     IEnumerable<Search.Query> queries,
     BooleanClause.Occur occur)
 {
     foreach (var query in queries)
     {
         bq.Add(query, occur);
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:10,代码来源:SrndBooleanQuery.cs

示例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;
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:12,代码来源:SrndBooleanQuery.cs

示例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;
        }
开发者ID:katebutenko,项目名称:SitecoreSearchContrib,代码行数:13,代码来源:NumericRangeSearchParam.cs

示例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;
        }
开发者ID:mebinum,项目名称:AdvanceDb,代码行数:13,代码来源:DateRangeSearchParam.cs

示例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);
        }
开发者ID:katebutenko,项目名称:SitecoreSearchContrib,代码行数:19,代码来源:QueryRunner.cs

示例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;
        }
开发者ID:juaqaai,项目名称:CompanyGroup,代码行数:22,代码来源:LuceneSearchBuilder.cs


注:本文中的Lucene.Net.Search.BooleanClause类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。