• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Search.BooleanClause类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Lucene.Net.Search.BooleanClause的典型用法代码示例。如果您正苦于以下问题:C# BooleanClause类的具体用法?C# BooleanClause怎么用?C# BooleanClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BooleanClause类属于Lucene.Net.Search命名空间,在下文中一共展示了BooleanClause类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: AddDateRangeQuery

        protected void AddDateRangeQuery(BooleanQuery query, DateRange dateRangeField, BooleanClause.Occur occurance)
        {
            var startDateTime = dateRangeField.StartDate;
             var endDateTime = dateRangeField.EndDate;

             if (dateRangeField.InclusiveStart && startDateTime > DateTime.MinValue.AddDays(1))
             {
            startDateTime = startDateTime.AddDays(-1);
             }

             if (dateRangeField.InclusiveEnd && endDateTime < DateTime.MaxValue.AddDays(-1))
             {
            endDateTime = endDateTime.AddDays(1);
             }

             // converting to lucene format
             var startDate = DateTools.DateToString(startDateTime, DateTools.Resolution.DAY);
             var endDate = DateTools.DateToString(endDateTime, DateTools.Resolution.DAY);

             var rangeQuery = new RangeQuery(new Term(dateRangeField.FieldName, startDate), new Term(dateRangeField.FieldName, endDate), true);
             query.Add(rangeQuery, occurance);
        }
开发者ID:mebinum,项目名称:AdvanceDb,代码行数:22,代码来源:DateRangeSearchParam.cs


示例17: BuildDateRangeSearchParam

        public static Query BuildDateRangeSearchParam(IEnumerable<DateRangeSearchParam.DateRange> ranges, BooleanClause.Occur condition)
        {
            Assert.ArgumentNotNull(ranges, "Ranges");

            if (!ranges.Any())
            {
                return null;
            }

            if (ranges.Count() == 1)
            {
                return BuildDateRangeQuery(ranges.First());
            }

            var innerQuery = new BooleanQuery();
            foreach (var range in ranges)
            {
                innerQuery.Add(BuildDateRangeQuery(range), condition);
            }

            return innerQuery;
        }
开发者ID:NetworkTen,项目名称:SitecoreSearchContrib,代码行数:22,代码来源:QueryBuilder.cs


示例18: VisitBooleanClauses

 public virtual BooleanClause[] VisitBooleanClauses(BooleanClause[] clauses)
 {
     List<BooleanClause> newList = null;
     int index = 0;
     int count = clauses.Length;
     while (index < count)
     {
         var visitedClause = VisitBooleanClause(clauses[index]);
         if (newList != null)
         {
             newList.Add(visitedClause);
         }
         else if (visitedClause != clauses[index])
         {
             newList = new List<BooleanClause>();
             for (int i = 0; i < index; i++)
                 newList.Add(clauses[i]);
             newList.Add(visitedClause);
         }
         index++;
     }
     return newList != null ? newList.ToArray() : clauses;
 }
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:23,代码来源:LucQueryVisitor.cs


示例19: Add

 /// <summary>Adds a clause to a boolean query.
 /// 
 /// </summary>
 /// <throws>  TooManyClauses if the new number of clauses exceeds the maximum clause number </throws>
 /// <seealso cref="#GetMaxClauseCount()">
 /// </seealso>
 public virtual void Add(Query query, BooleanClause.Occur occur)
 {
     Add(new BooleanClause(query, occur));
 }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:10,代码来源:BooleanQuery.cs


示例20: Add

 public override void Add(Search.Query query, BooleanClause.Occur occur)
 {
     throw new NotSupportedException();
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:4,代码来源:SrndQuery.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Library.EdmEntityType类代码示例发布时间:2022-05-27
下一篇:
C# Models.User类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap