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


C# PhraseQuery.GetTerms方法代码示例

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


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

示例1: VisitPhraseQuery

        public override Query VisitPhraseQuery(PhraseQuery phraseq)
        {
            _dump.Append("PhraseQ(");

            var terms = phraseq.GetTerms();
            PhraseQuery newQuery = null;

            int index = 0;
            int count = terms.Length;
            while (index < count)
            {
                var visitedTerm = VisitTerm(terms[index]);
                if (newQuery != null)
                {
                    newQuery.Add(visitedTerm);
                }
                else if (visitedTerm != terms[index])
                {
                    newQuery = new PhraseQuery();
                    for (int i = 0; i < index; i++)
                        newQuery.Add(terms[i]);
                    newQuery.Add(visitedTerm);
                }
                index++;
                if (index < count)
                    _dump.Append(", ");
            }
            _dump.Append(", Slop:").Append(phraseq.GetSlop()).Append(BoostToString(phraseq)).Append(")");
            if (newQuery != null)
                return newQuery;
            return phraseq;
        }
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:32,代码来源:DumpVisitor.cs

示例2: CheckOverlap

 /*
  * Check if PhraseQuery A and B have overlapped part.
  * 
  * ex1) A="a b", B="b c" => overlap; expandQueries={"a b c"}
  * ex2) A="b c", B="a b" => overlap; expandQueries={"a b c"}
  * ex3) A="a b", B="c d" => no overlap; expandQueries={}
  */
 private void CheckOverlap(Dictionary<Query, Query> expandQueries, PhraseQuery a, PhraseQuery b)
 {
     if (a.Slop != b.Slop) return;
     Term[] ats = a.GetTerms();
     Term[] bts = b.GetTerms();
     if (fieldMatch && !ats[0].Field.Equals(bts[0].Field)) return;
     CheckOverlap(expandQueries, ats, bts, a.Slop, a.Boost);
     CheckOverlap(expandQueries, bts, ats, b.Slop, b.Boost);
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:16,代码来源:FieldQuery.cs

示例3: VisitQuery

 private static void VisitQuery(PhraseQuery query, AzureQueryLogger.IndentedTextWriter writer)
 {
     writer.WriteLine("Slop: {0}", (object)query.Slop);
     foreach (Term term in query.GetTerms())
         AzureQueryLogger.VisitTerm(term, writer);
 }
开发者ID:jscott1277,项目名称:SitecoreAzureSearchProvider,代码行数:6,代码来源:AzureQueryLogger.cs

示例4: TranslatePhraseQuery

 private SectionSearchQueryPlan TranslatePhraseQuery(PhraseQuery query)
 {
     Term[] terms = query.GetTerms();
     TermNode[] nodes = new TermNode[terms.Length];
     int[] positions = query.GetPositions();
     for (int i = 0; i < terms.Length; i++)
     {
         nodes[i] = new TermNode(terms[i], positions[i], _reader);
     }
     return new PhraseNode(nodes, _reader);
 }
开发者ID:yao-yi,项目名称:BoboBrowse.Net,代码行数:11,代码来源:SectionSearchQueryPlanBuilder.cs

示例5: BuildPhrase

        private ParameterizedSql BuildPhrase(PhraseQuery phraseQuery)
        {
            var termsAdded = 0;
            var field = "";
            var queryStringBuilder = new StringBuilder();

            foreach (var term in phraseQuery.GetTerms())
            {
                if (termsAdded == 0)
                {
                    field = term.Field;
                }
                else if (termsAdded > 0)
                {
                    queryStringBuilder.Append(" ");
                }

                queryStringBuilder.Append(term.Text);

                termsAdded++;
            }

            Query query;
            var queryString = queryStringBuilder.ToString();

            if (queryString.Contains("?") || queryString.Contains("*"))
            {
                query = new WildcardQuery(new Term(field, queryString));
            }
            else
            {
                query = new TermQuery(new Term(field, queryString));
            }

            return Build(query);
        }
开发者ID:tomvonclef,项目名称:LuceneQueryToSql,代码行数:36,代码来源:QueryBuilder.cs

示例6: VisitPhraseQuery

        public override Query VisitPhraseQuery(PhraseQuery phraseq)
        {
            var terms = phraseq.GetTerms();
            PhraseQuery newQuery = null;

            int index = 0;
            int count = terms.Length;
            while (index < count)
            {
                var visitedTerm = VisitTerm(terms[index]);
                if (newQuery != null)
                {
                    if (visitedTerm != null)
                        newQuery.Add(visitedTerm);
                }
                else if (visitedTerm != terms[index])
                {
                    newQuery = new PhraseQuery();
                    for (int i = 0; i < index; i++)
                        newQuery.Add(terms[i]);
                    if (visitedTerm != null)
                        newQuery.Add(visitedTerm);
                }
                index++;
            }
            if (newQuery != null)
            {
                if (newQuery.GetTerms().Length > 0)
                    return newQuery;
                return null;
            }
            return phraseq;
        }
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:33,代码来源:LucQueryVisitor.cs

示例7: VisitPhraseQuery

 protected virtual PhraseQuery VisitPhraseQuery(PhraseQuery p)
 {
     var qry = new PhraseQuery();
     foreach (var t in p.GetTerms())
     {
         qry.Add(VisitTerm(t));
     }
     return qry;
 }
开发者ID:daszat,项目名称:zetbox,代码行数:9,代码来源:QueryTranslator.cs


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