Example #1
0
            protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
            {
                Entry entry = (Entry)entryKey;

                System.String  field      = entry.field;
                SortComparator comparator = (SortComparator)entry.custom;

                System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()];
                TermDocs             termDocs = reader.TermDocs();
                TermEnum             termEnum = reader.Terms(new Term(field));

                try
                {
                    do
                    {
                        Term term = termEnum.Term();
                        if (term == null || (System.Object)term.Field() != (System.Object)field)
                        {
                            break;
                        }
                        System.IComparable termval = comparator.GetComparable(term.Text());
                        termDocs.Seek(termEnum);
                        while (termDocs.Next())
                        {
                            retArray[termDocs.Doc()] = termval;
                        }
                    }while (termEnum.Next());
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }
                return(retArray);
            }
Example #2
0
            protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
            {
                System.String   field    = StringHelper.Intern((System.String)entryKey.field);
                System.String[] retArray = new System.String[reader.MaxDoc()];
                TermDocs        termDocs = reader.TermDocs();
                TermEnum        termEnum = reader.Terms(new Term(field));

                try
                {
                    do
                    {
                        Term term = termEnum.Term();
                        if (term == null || (System.Object)term.Field() != (System.Object)field)
                        {
                            break;
                        }
                        System.String termval = term.Text();
                        termDocs.Seek(termEnum);
                        while (termDocs.Next())
                        {
                            retArray[termDocs.Doc()] = termval;
                        }
                    }while (termEnum.Next());
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }
                return(retArray);
            }
Example #3
0
			internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w, byte[] norms):base(similarity)
			{
				InitBlock(enclosingInstance);
				this.termDocs = reader.TermDocs(null);
				score = w.GetValue();
				this.norms = norms;
			}
Example #4
0
 internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w, byte[] norms) : base(similarity)
 {
     InitBlock(enclosingInstance);
     this.termDocs = reader.TermDocs(null);
     score         = w.GetValue();
     this.norms    = norms;
 }
Example #5
0
            protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
            {
                Entry entry = (Entry)entryKey;

                System.String field  = entry.field;
                FloatParser   parser = (FloatParser)entry.custom;

                if (parser == null)
                {
                    try
                    {
                        return(wrapper.GetFloats(reader, field, Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT_FLOAT_PARSER));
                    }
                    catch (System.FormatException ne)
                    {
                        return(wrapper.GetFloats(reader, field, Mono.Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_FLOAT_PARSER));
                    }
                }
                float[]  retArray = null;
                TermDocs termDocs = reader.TermDocs();
                TermEnum termEnum = reader.Terms(new Term(field));

                try
                {
                    do
                    {
                        Term term = termEnum.Term();
                        if (term == null || (System.Object)term.Field() != (System.Object)field)
                        {
                            break;
                        }
                        float termval = parser.ParseFloat(term.Text());
                        if (retArray == null)
                        {
                            // late init
                            retArray = new float[reader.MaxDoc()];
                        }
                        termDocs.Seek(termEnum);
                        while (termDocs.Next())
                        {
                            retArray[termDocs.Doc()] = termval;
                        }
                    }while (termEnum.Next());
                }
                catch (StopFillCacheException stop)
                {
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }
                if (retArray == null)
                {
                    // no values
                    retArray = new float[reader.MaxDoc()];
                }
                return(retArray);
            }
Example #6
0
 // constructor
 internal ValueSourceScorer(ValueSourceQuery enclosingInstance, Similarity similarity, IndexReader reader, ValueSourceWeight w) : base(similarity)
 {
     InitBlock(enclosingInstance);
     this.weight  = w;
     this.qWeight = w.GetValue();
     // this is when/where the values are first created.
     vals     = Enclosing_Instance.valSrc.GetValues(reader);
     termDocs = reader.TermDocs(null);
 }
Example #7
0
		/// <summary> Construct a <code>TermScorer</code>.
		/// 
		/// </summary>
		/// <param name="weight">The weight of the <code>Term</code> in the query.
		/// </param>
		/// <param name="td">An iterator over the documents matching the <code>Term</code>.
		/// </param>
		/// <param name="similarity">The <code>Similarity</code> implementation to be used for score
		/// computations.
		/// </param>
		/// <param name="norms">The field norms of the document fields for the <code>Term</code>.
		/// </param>
		public /*internal*/ TermScorer(Weight weight, TermDocs td, Similarity similarity, byte[] norms):base(similarity)
		{
			this.weight = weight;
			this.termDocs = td;
			this.norms = norms;
			this.weightValue = weight.GetValue();
			
			for (int i = 0; i < SCORE_CACHE_SIZE; i++)
				scoreCache[i] = GetSimilarity().Tf(i) * weightValue;
		}
Example #8
0
            public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
            {
                TermDocs termDocs = reader.TermDocs(Enclosing_Instance.term);

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

                return(new TermScorer(this, termDocs, similarity, reader.Norms(Enclosing_Instance.term.Field())));
            }
Example #9
0
        /// <summary> Construct a <code>TermScorer</code>.
        ///
        /// </summary>
        /// <param name="weight">The weight of the <code>Term</code> in the query.
        /// </param>
        /// <param name="td">An iterator over the documents matching the <code>Term</code>.
        /// </param>
        /// <param name="similarity">The <code>Similarity</code> implementation to be used for score
        /// computations.
        /// </param>
        /// <param name="norms">The field norms of the document fields for the <code>Term</code>.
        /// </param>
        public /*internal*/ TermScorer(Weight weight, TermDocs td, Similarity similarity, byte[] norms) : base(similarity)
        {
            this.weight      = weight;
            this.termDocs    = td;
            this.norms       = norms;
            this.weightValue = weight.GetValue();

            for (int i = 0; i < SCORE_CACHE_SIZE; i++)
            {
                scoreCache[i] = GetSimilarity().Tf(i) * weightValue;
            }
        }
Example #10
0
            protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
            {
                Entry entry = (Entry)entryKey;

                System.String field  = entry.field;
                ShortParser   parser = (ShortParser)entry.custom;

                if (parser == null)
                {
                    return(wrapper.GetShorts(reader, field, Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT_SHORT_PARSER));
                }
                short[]  retArray = new short[reader.MaxDoc()];
                TermDocs termDocs = reader.TermDocs();
                TermEnum termEnum = reader.Terms(new Term(field));

                try
                {
                    do
                    {
                        Term term = termEnum.Term();
                        if (term == null || (System.Object)term.Field() != (System.Object)field)
                        {
                            break;
                        }
                        short termval = parser.ParseShort(term.Text());
                        termDocs.Seek(termEnum);
                        while (termDocs.Next())
                        {
                            retArray[termDocs.Doc()] = termval;
                        }
                    }while (termEnum.Next());
                }
                catch (StopFillCacheException stop)
                {
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }
                return(retArray);
            }
            public virtual void Generate(MultiTermQuery query, IndexReader reader, TermEnum enumerator)
            {
                int[]    docs     = new int[32];
                int[]    freqs    = new int[32];
                TermDocs termDocs = reader.TermDocs();

                try
                {
                    int termCount = 0;
                    do
                    {
                        Term term = enumerator.Term();
                        if (term == null)
                        {
                            break;
                        }
                        termCount++;
                        termDocs.Seek(term);
                        while (true)
                        {
                            int count = termDocs.Read(docs, freqs);
                            if (count != 0)
                            {
                                for (int i = 0; i < count; i++)
                                {
                                    HandleDoc(docs[i]);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }while (enumerator.Next());

                    query.IncTotalNumberOfTerms(termCount);                     // {{Aroush-2.9}} is the use of 'temp' as is right?
                }
                finally
                {
                    termDocs.Close();
                }
            }
Example #12
0
            protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
            {
                System.String   field    = StringHelper.Intern((System.String)entryKey.field);
                int[]           retArray = new int[reader.MaxDoc()];
                System.String[] mterms   = new System.String[reader.MaxDoc() + 1];
                TermDocs        termDocs = reader.TermDocs();
                TermEnum        termEnum = reader.Terms(new Term(field));
                int             t        = 0; // current term number

                // an entry for documents that have no terms in this field
                // should a document with no terms be at top or bottom?
                // this puts them at the top - if it is changed, FieldDocSortedHitQueue
                // needs to change as well.
                mterms[t++] = null;

                try
                {
                    do
                    {
                        Term term = termEnum.Term();
                        if (term == null || term.Field() != field || t >= mterms.Length)
                        {
                            break;
                        }

                        // store term text
                        mterms[t] = term.Text();

                        termDocs.Seek(termEnum);
                        while (termDocs.Next())
                        {
                            retArray[termDocs.Doc()] = t;
                        }

                        t++;
                    }while (termEnum.Next());
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }

                if (t == 0)
                {
                    // if there are no terms, make the term array
                    // have a single null entry
                    mterms = new System.String[1];
                }
                else if (t < mterms.Length)
                {
                    // if there are less terms than documents,
                    // trim off the dead array space
                    System.String[] terms = new System.String[t];
                    Array.Copy(mterms, 0, terms, 0, t);
                    mterms = terms;
                }

                StringIndex value_Renamed = new StringIndex(retArray, mterms);

                return(value_Renamed);
            }
Example #13
0
			// constructor
			internal ValueSourceScorer(ValueSourceQuery enclosingInstance, Similarity similarity, IndexReader reader, ValueSourceWeight w):base(similarity)
			{
				InitBlock(enclosingInstance);
				this.weight = w;
				this.qWeight = w.GetValue();
				// this is when/where the values are first created.
				vals = Enclosing_Instance.valSrc.GetValues(reader);
				termDocs = reader.TermDocs(null);
			}