示例#1
0
            public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer, IState state)
            {
                if (Enclosing_Instance.terms.Count == 0)
                {
                    // optimize zero-term case
                    return(null);
                }

                TermPositions[] tps = new TermPositions[Enclosing_Instance.terms.Count];
                for (int i = 0; i < Enclosing_Instance.terms.Count; i++)
                {
                    TermPositions p = reader.TermPositions(Enclosing_Instance.terms[i], state);
                    if (p == null)
                    {
                        return(null);
                    }
                    tps[i] = p;
                }

                if (Enclosing_Instance.slop == 0)
                {
                    // optimize exact case
                    return(new ExactPhraseScorer(this, tps, Enclosing_Instance.GetPositions(), similarity, reader.Norms(Enclosing_Instance.field, state)));
                }
                else
                {
                    return(new SloppyPhraseScorer(this, tps, Enclosing_Instance.GetPositions(), similarity, Enclosing_Instance.slop, reader.Norms(Enclosing_Instance.field, state)));
                }
            }
            public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
            {
                if (Enclosing_Instance.termArrays.Count == 0)
                {
                    // optimize zero-term case
                    return(null);
                }

                TermPositions[] tps = new TermPositions[Enclosing_Instance.termArrays.Count];
                for (int i = 0; i < tps.Length; i++)
                {
                    Term[] terms = Enclosing_Instance.termArrays[i];

                    TermPositions p;
                    if (terms.Length > 1)
                    {
                        p = new MultipleTermPositions(reader, terms);
                    }
                    else
                    {
                        p = reader.TermPositions(terms[0]);
                    }

                    if (p == null)
                    {
                        return(null);
                    }

                    tps[i] = p;
                }

                if (Enclosing_Instance.slop == 0)
                {
                    return(new ExactPhraseScorer(this, tps, Enclosing_Instance.GetPositions(), similarity, reader.Norms(Enclosing_Instance.field)));
                }
                else
                {
                    return(new SloppyPhraseScorer(this, tps, Enclosing_Instance.GetPositions(), similarity, Enclosing_Instance.slop, reader.Norms(Enclosing_Instance.field)));
                }
            }