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


C# Vectorhighlight.FieldQuery类代码示例

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


FieldQuery类属于Lucene.Net.Search.Vectorhighlight命名空间,在下文中一共展示了FieldQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FieldPhraseList

        /// <summary>
        /// a constructor. 
        /// </summary>
        /// <param name="fieldTermStack">FieldTermStack object</param>
        /// <param name="fieldQuery">FieldQuery object</param>
        /// <param name="phraseLimit">maximum size of phraseList</param>
        public FieldPhraseList(FieldTermStack fieldTermStack, FieldQuery fieldQuery, int phraseLimit)
        {
            String field = fieldTermStack.FieldName;

            LinkedList<TermInfo> phraseCandidate = new LinkedList<TermInfo>();
            QueryPhraseMap currMap = null;
            QueryPhraseMap nextMap = null;
            while (!fieldTermStack.IsEmpty() && (phraseList.Count < phraseLimit) )
            {

                phraseCandidate.Clear();

                TermInfo ti = fieldTermStack.Pop();
                currMap = fieldQuery.GetFieldTermMap(field, ti.Text);

                // if not found, discard top TermInfo from stack, then try next element
                if (currMap == null) continue;

                // if found, search the longest phrase
                phraseCandidate.AddLast(ti);
                while (true)
                {
                    ti = fieldTermStack.Pop();
                    nextMap = null;
                    if (ti != null)
                        nextMap = currMap.GetTermMap(ti.Text);
                    if (ti == null || nextMap == null)
                    {
                        if (ti != null)
                            fieldTermStack.Push(ti);
                        if (currMap.IsValidTermOrPhrase(new List<TermInfo>(phraseCandidate)))
                        {
                            AddIfNoOverlap(new WeightedPhraseInfo(phraseCandidate, currMap.Boost, currMap.TermOrPhraseNumber));
                        }
                        else
                        {
                            while (phraseCandidate.Count > 1)
                            {
                                TermInfo last = phraseCandidate.Last.Value;
                                phraseCandidate.RemoveLast();
                                fieldTermStack.Push(last);
                                currMap = fieldQuery.SearchPhrase(field, new List<TermInfo>(phraseCandidate));
                                if (currMap != null)
                                {
                                    AddIfNoOverlap(new WeightedPhraseInfo(phraseCandidate, currMap.Boost, currMap.TermOrPhraseNumber));
                                    break;
                                }
                            }
                        }
                        break;
                    }
                    else
                    {
                        phraseCandidate.AddLast(ti);
                        currMap = nextMap;
                    }
                }
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:65,代码来源:FieldPhraseList.cs

示例2: TestFlatten1TermPhrase

 public void TestFlatten1TermPhrase()
 {
     Query query = PqF("A");
     FieldQuery fq = new FieldQuery(query, true, true);
     HashSet<Query> flatQueries = new HashSet<Query>();
     fq.flatten(query, flatQueries);
     AssertCollectionQueries(flatQueries, Tq("A"));
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:8,代码来源:FieldQueryTest.cs

示例3: TestFlattenTermAndPhrase2gram

 public void TestFlattenTermAndPhrase2gram()
 {
     Query query = paB.Parse("AA AND BCD OR EFGH");
     FieldQuery fq = new FieldQuery(query, true, true);
     HashSet<Query> flatQueries = new HashSet<Query>();
     fq.flatten(query, flatQueries);
     AssertCollectionQueries(flatQueries, Tq("AA"), PqF("BC", "CD" ), PqF("EF", "FG", "GH"));
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:8,代码来源:FieldQueryTest.cs

示例4: TestFlattenTermAndPhrase

 public void TestFlattenTermAndPhrase()
 {
     Query query = paW.Parse("A AND \"B C\"");
     FieldQuery fq = new FieldQuery(query, true, true);
     HashSet<Query> flatQueries = new HashSet<Query>();
     fq.flatten(query, flatQueries);
     AssertCollectionQueries(flatQueries, Tq("A"), PqF("B", "C"));
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:8,代码来源:FieldQueryTest.cs

示例5: testFlattenDisjunctionMaxQuery

 public void testFlattenDisjunctionMaxQuery()
 {
     Query query = Dmq(Tq("A"), Tq("B"), PqF("C", "D"));
     FieldQuery fq = new FieldQuery(query, true, true);
     HashSet<Query> flatQueries = new HashSet<Query>();
     fq.flatten(query, flatQueries);
     AssertCollectionQueries(flatQueries, Tq("A"), Tq("B"), PqF("C", "D"));
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:8,代码来源:FieldQueryTest.cs

示例6: TestFlattenBoolean

 public void TestFlattenBoolean()
 {
     Query query = paW.Parse("A AND B OR C NOT (D AND E)");
     FieldQuery fq = new FieldQuery(query, true, true);
     HashSet<Query> flatQueries = new HashSet<Query>();
     fq.flatten(query, flatQueries);
     AssertCollectionQueries(flatQueries, Tq("A"), Tq("B"), Tq("C"));
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:8,代码来源:FieldQueryTest.cs

示例7: TestFieldTermStackIndex1w2wSearch1term

        public void TestFieldTermStackIndex1w2wSearch1term()
        {
            MakeIndex1w2w();

            FieldQuery fq = new FieldQuery(Tq("pc"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            Assert.AreEqual(1, stack.termList.Count);
            Assert.AreEqual("pc(3,5,1)", stack.Pop().ToString());
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:9,代码来源:IndexTimeSynonymTest.cs

示例8: Ffl

 private FieldFragList Ffl(String queryValue, String indexValue)
 {
     Make1d1fIndex(indexValue);
     Query query = paW.Parse(queryValue);
     FieldQuery fq = new FieldQuery(query, true, true);
     FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
     FieldPhraseList fpl = new FieldPhraseList(stack, fq);
     return new SimpleFragListBuilder().CreateFieldFragList(fpl, 20);
 }
开发者ID:hanabi1224,项目名称:lucene.net,代码行数:9,代码来源:ScoreOrderFragmentsBuilderTest.cs

示例9: TestFieldTermStackIndex1w2wSearch1phrase

        public void TestFieldTermStackIndex1w2wSearch1phrase()
        {
            MakeIndex1w2w();

            FieldQuery fq = new FieldQuery(PqF("personal", "computer"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            Assert.AreEqual(2, stack.termList.Count);
            Assert.AreEqual("personal(3,5,1)", stack.Pop().ToString());
            Assert.AreEqual("computer(3,5,2)", stack.Pop().ToString());
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:10,代码来源:IndexTimeSynonymTest.cs

示例10: Test1Phrase

        public void Test1Phrase()
        {
            MakeIndex();

            FieldQuery fq = new FieldQuery(PqF("c", "d"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            Assert.AreEqual(3, stack.termList.Count);
            Assert.AreEqual("c(10,11,5)", stack.Pop().ToString());
            Assert.AreEqual("c(18,19,9)", stack.Pop().ToString());
            Assert.AreEqual("d(20,21,10)", stack.Pop().ToString());
        }
开发者ID:synhershko,项目名称:lucene.net,代码行数:11,代码来源:FieldTermStackTest.cs

示例11: Test2TermsIndex

        public void Test2TermsIndex()
        {
            Make1d1fIndex("a a");

            FieldQuery fq = new FieldQuery(Tq("a"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(2, fpl.phraseList.Count);
            Assert.AreEqual("a(1.0)((0,1))", fpl.phraseList.First.Value.ToString());
            Assert.AreEqual("a(1.0)((2,3))", fpl.phraseList.First.Next.Value.ToString());
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:11,代码来源:FieldPhraseListTest.cs

示例12: Test1Term

        public void Test1Term()
        {
            MakeIndex();

            FieldQuery fq = new FieldQuery(Tq("a"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            Assert.AreEqual(6, stack.termList.Count);
            Assert.AreEqual("a(0,1,0)", stack.Pop().ToString());
            Assert.AreEqual("a(2,3,1)", stack.Pop().ToString());
            Assert.AreEqual("a(4,5,2)", stack.Pop().ToString());
            Assert.AreEqual("a(12,13,6)", stack.Pop().ToString());
            Assert.AreEqual("a(28,29,14)", stack.Pop().ToString());
            Assert.AreEqual("a(32,33,16)", stack.Pop().ToString());
        }
开发者ID:synhershko,项目名称:lucene.net,代码行数:14,代码来源:FieldTermStackTest.cs

示例13: Test1PhraseIndex

        public void Test1PhraseIndex()
        {
            Make1d1fIndex("a b");

            FieldQuery fq = new FieldQuery(PqF("a", "b"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.AreEqual("ab(1.0)((0,3))", fpl.phraseList.First.Value.ToString());

            fq = new FieldQuery(Tq("b"), true, true);
            stack = new FieldTermStack(reader, 0, F, fq);
            fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.AreEqual("b(1.0)((2,3))", fpl.phraseList.First.Value.ToString());
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:16,代码来源:FieldPhraseListTest.cs

示例14: TestFieldTermStackIndex1wSearch2terms

        public void TestFieldTermStackIndex1wSearch2terms()
        {
            MakeIndex1w();

            BooleanQuery bq = new BooleanQuery();
            bq.Add(Tq("Mac"), Occur.SHOULD);
            bq.Add(Tq("MacBook"), Occur.SHOULD);
            FieldQuery fq = new FieldQuery(bq, true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            Assert.AreEqual(2, stack.termList.Count);
            Dictionary<String, String> expectedSet = new Dictionary<String, String>();
            expectedSet.Add("Mac(11,20,3)","");
            expectedSet.Add("MacBook(11,20,3)","");
            Assert.IsTrue(expectedSet.ContainsKey(stack.Pop().ToString()));
            Assert.IsTrue(expectedSet.ContainsKey(stack.Pop().ToString()));
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:16,代码来源:IndexTimeSynonymTest.cs

示例15: Test2Terms

        public void Test2Terms()
        {
            MakeIndex();

            BooleanQuery query = new BooleanQuery();
            query.Add(Tq("b"), Occur.SHOULD);
            query.Add(Tq("c"), Occur.SHOULD);
            FieldQuery fq = new FieldQuery(query, true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            Assert.AreEqual(8, stack.termList.Count);
            Assert.AreEqual("b(6,7,3)", stack.Pop().ToString());
            Assert.AreEqual("b(8,9,4)", stack.Pop().ToString());
            Assert.AreEqual("c(10,11,5)", stack.Pop().ToString());
            Assert.AreEqual("b(14,15,7)", stack.Pop().ToString());
            Assert.AreEqual("b(16,17,8)", stack.Pop().ToString());
            Assert.AreEqual("c(18,19,9)", stack.Pop().ToString());
            Assert.AreEqual("b(26,27,13)", stack.Pop().ToString());
            Assert.AreEqual("b(30,31,15)", stack.Pop().ToString());
        }
开发者ID:synhershko,项目名称:lucene.net,代码行数:19,代码来源:FieldTermStackTest.cs


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