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


C# TermRangeQuery.SetRewriteMethod方法代码示例

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


在下文中一共展示了TermRangeQuery.SetRewriteMethod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssertSame

        /// <summary>
        /// check that the # of hits is the same as if the query
        /// is run against the inverted index
        /// </summary>
        protected internal virtual void AssertSame(BytesRef lowerVal, BytesRef upperVal, bool includeLower, bool includeUpper)
        {
            Query docValues = new ConstantScoreQuery(DocTermOrdsRangeFilter.NewBytesRefRange(FieldName, lowerVal, upperVal, includeLower, includeUpper));
            MultiTermQuery inverted = new TermRangeQuery(FieldName, lowerVal, upperVal, includeLower, includeUpper);
            inverted.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);

            TopDocs invertedDocs = Searcher1.Search(inverted, 25);
            TopDocs docValuesDocs = Searcher2.Search(docValues, 25);

            CheckHits.CheckEqual(inverted, invertedDocs.ScoreDocs, docValuesDocs.ScoreDocs);
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:15,代码来源:TestDocTermOrdsRangeFilter.cs

示例2: RangeQuery

        /// <summary>Constructs a query selecting all terms greater than
        /// <c>lowerTerm</c> but less than <c>upperTerm</c>.
        /// There must be at least one term and either term may be null,
        /// in which case there is no bound on that side, but if there are
        /// two terms, both terms <b>must</b> be for the same field.
        /// <p/>
        /// If <c>collator</c> is not null, it will be used to decide whether
        /// index terms are within the given range, rather than using the Unicode code
        /// point order in which index terms are stored.
        /// <p/>
        /// <strong>WARNING:</strong> Using this constructor and supplying a non-null
        /// value in the <c>collator</c> parameter will cause every single 
        /// index Term in the Field referenced by lowerTerm and/or upperTerm to be
        /// examined.  Depending on the number of index Terms in this Field, the 
        /// operation could be very slow.
        /// 
        /// </summary>
        /// <param name="lowerTerm">The Term at the lower end of the range
        /// </param>
        /// <param name="upperTerm">The Term at the upper end of the range
        /// </param>
        /// <param name="inclusive">If true, both <c>lowerTerm</c> and
        /// <c>upperTerm</c> will themselves be included in the range.
        /// </param>
        /// <param name="collator">The collator to use to collate index Terms, to determine
        /// their membership in the range bounded by <c>lowerTerm</c> and
        /// <c>upperTerm</c>.
        /// </param>
        public RangeQuery(Term lowerTerm, Term upperTerm, bool inclusive, System.Globalization.CompareInfo collator)
        {
            if (lowerTerm == null && upperTerm == null)
                throw new System.ArgumentException("At least one term must be non-null");
            if (lowerTerm != null && upperTerm != null && (System.Object) lowerTerm.Field() != (System.Object) upperTerm.Field())
                throw new System.ArgumentException("Both terms must have the same field");

            delegate_Renamed = new TermRangeQuery((lowerTerm == null)?upperTerm.Field():lowerTerm.Field(), (lowerTerm == null)?null:lowerTerm.Text(), (upperTerm == null)?null:upperTerm.Text(), inclusive, inclusive, collator);
            delegate_Renamed.SetRewriteMethod(TermRangeQuery.SCORING_BOOLEAN_QUERY_REWRITE);
        }
开发者ID:sinsay,项目名称:SSE,代码行数:38,代码来源:RangeQuery.cs

示例3: Csrq

		/// <summary>macro for readability </summary>
		public static Query Csrq(System.String f, System.String l, System.String h, bool il, bool ih, System.Globalization.CompareInfo c)
		{
			TermRangeQuery query = new TermRangeQuery(f, l, h, il, ih, c);
			query.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
			return query;
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:7,代码来源:TestMultiTermConstantScore.cs

示例4: CheckBooleanTerms

 private void CheckBooleanTerms(IndexSearcher searcher, TermRangeQuery query, params string[] terms)
 {
     query.SetRewriteMethod(new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(50));
     BooleanQuery bq = (BooleanQuery)searcher.Rewrite(query);
     var allowedTerms = AsSet(terms);
     Assert.AreEqual(allowedTerms.Count, bq.Clauses.Length);
     foreach (BooleanClause c in bq.Clauses)
     {
         Assert.IsTrue(c.Query is TermQuery);
         TermQuery tq = (TermQuery)c.Query;
         string term = tq.Term.Text();
         Assert.IsTrue(allowedTerms.Contains(term), "invalid term: " + term);
         allowedTerms.Remove(term); // remove to fail on double terms
     }
     Assert.AreEqual(0, allowedTerms.Count);
 }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:16,代码来源:TestTermRangeQuery.cs

示例5: NewRangeQuery

        /// <summary>
        /// Builds a new {@link TermRangeQuery} instance
        /// </summary>
        /// <param name="field">Field</param>
        /// <param name="part1">min</param>
        /// <param name="part2">max</param>
        /// <param name="startInclusive">true if the start of the range is inclusive</param>
        /// <param name="endInclusive">true if the end of the range is inclusive</param>
        /// <returns>new <see cref="T:TermRangeQuery"/> instance</returns>
        protected internal virtual Query NewRangeQuery(string field, string part1, string part2, bool startInclusive, bool endInclusive)
        {
            BytesRef start;
            BytesRef end;

            if (part1 == null)
            {
                start = null;
            }
            else
            {
                start = AnalyzeRangeTerms ? AnalyzeMultitermTerm(field, part1) : new BytesRef(part1);
            }

            if (part2 == null)
            {
                end = null;
            }
            else
            {
                end = AnalyzeRangeTerms ? AnalyzeMultitermTerm(field, part2) : new BytesRef(part2);
            }

            TermRangeQuery query = new TermRangeQuery(field, start, end, startInclusive, endInclusive);

            query.SetRewriteMethod(MultiTermRewriteMethod);
            return query;
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:37,代码来源:QueryParserBase.cs


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