Exemplo n.º 1
0
        /*(non-Javadoc) <see cref="Lucene.Net.Search.Query.rewrite(Lucene.Net.Index.IndexReader) */
        public override Query Rewrite(IndexReader reader)
        {
            CustomScoreQuery clone = null;

            Query sq = subQuery.Rewrite(reader);

            if (sq != subQuery)
            {
                clone          = (CustomScoreQuery)Clone();
                clone.subQuery = sq;
            }

            for (int i = 0; i < valSrcQueries.Length; i++)
            {
                ValueSourceQuery v = (ValueSourceQuery)valSrcQueries[i].Rewrite(reader);
                if (v != valSrcQueries[i])
                {
                    if (clone == null)
                    {
                        clone = (CustomScoreQuery)Clone();
                    }
                    clone.valSrcQueries[i] = v;
                }
            }

            return((clone == null) ? this : clone);
        }
Exemplo n.º 2
0
            private float[] vScores;             // reused in score() to avoid allocating this array for each doc

            // constructor
            internal CustomScorer(CustomScoreQuery enclosingInstance, Similarity similarity, IndexReader reader, CustomWeight w, Scorer subQueryScorer, Scorer[] valSrcScorers) : base(similarity)
            {
                InitBlock(enclosingInstance);
                this.qWeight        = w.Value;
                this.subQueryScorer = subQueryScorer;
                this.valSrcScorers  = valSrcScorers;
                this.reader         = reader;
                this.vScores        = new float[valSrcScorers.Length];
                this.provider       = this.Enclosing_Instance.GetCustomScoreProvider(reader);
            }
Exemplo n.º 3
0
 public CustomWeight(CustomScoreQuery enclosingInstance, Searcher searcher)
 {
     InitBlock(enclosingInstance);
     this.similarity     = Enclosing_Instance.GetSimilarity(searcher);
     this.subQueryWeight = Enclosing_Instance.subQuery.Weight(searcher);
     this.valSrcWeights  = new Weight[Enclosing_Instance.valSrcQueries.Length];
     for (int i = 0; i < Enclosing_Instance.valSrcQueries.Length; i++)
     {
         this.valSrcWeights[i] = Enclosing_Instance.valSrcQueries[i].CreateWeight(searcher);
     }
     this.qStrict = Enclosing_Instance.strict;
 }
Exemplo n.º 4
0
        /*(non-Javadoc) <see cref="Lucene.Net.Search.Query.clone() */
        public override System.Object Clone()
        {
            CustomScoreQuery clone = (CustomScoreQuery)base.Clone();

            clone.subQuery      = (Query)subQuery.Clone();
            clone.valSrcQueries = new ValueSourceQuery[valSrcQueries.Length];
            for (int i = 0; i < valSrcQueries.Length; i++)
            {
                clone.valSrcQueries[i] = (ValueSourceQuery)valSrcQueries[i].Clone();
            }
            return(clone);
        }
Exemplo n.º 5
0
        /// <summary>Returns true if <c>o</c> is equal to this. </summary>
        public override bool Equals(System.Object o)
        {
            if (GetType() != o.GetType())
            {
                return(false);
            }
            CustomScoreQuery other = (CustomScoreQuery)o;

            if (this.Boost != other.Boost ||
                !this.subQuery.Equals(other.subQuery) ||
                this.strict != other.strict ||
                this.valSrcQueries.Length != other.valSrcQueries.Length)
            {
                return(false);
            }

            // SequenceEqual should properly mimic java's Array.equals()
            return(valSrcQueries.SequenceEqual(other.valSrcQueries));
        }
Exemplo n.º 6
0
 private void  InitBlock(CustomScoreQuery enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Exemplo n.º 7
0
 public AnonymousCustomScoreProvider(CustomScoreQuery parent, IndexReader reader) : base(reader)
 {
     this.parent = parent;
 }
Exemplo n.º 8
0
			private float[] vScores; // reused in score() to avoid allocating this array for each doc 
			
			// constructor
			internal CustomScorer(CustomScoreQuery enclosingInstance, Similarity similarity, IndexReader reader, CustomWeight w, Scorer subQueryScorer, Scorer[] valSrcScorers):base(similarity)
			{
				InitBlock(enclosingInstance);
				this.qWeight = w.Value;
				this.subQueryScorer = subQueryScorer;
				this.valSrcScorers = valSrcScorers;
				this.reader = reader;
				this.vScores = new float[valSrcScorers.Length];
                this.provider = this.Enclosing_Instance.GetCustomScoreProvider(reader);
			}
Exemplo n.º 9
0
			private void  InitBlock(CustomScoreQuery enclosingInstance)
			{
				this.enclosingInstance = enclosingInstance;
			}
Exemplo n.º 10
0
			public CustomWeight(CustomScoreQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
				this.subQueryWeight = Enclosing_Instance.subQuery.Weight(searcher);
				this.valSrcWeights = new Weight[Enclosing_Instance.valSrcQueries.Length];
				for (int i = 0; i < Enclosing_Instance.valSrcQueries.Length; i++)
				{
					this.valSrcWeights[i] = Enclosing_Instance.valSrcQueries[i].CreateWeight(searcher);
				}
				this.qStrict = Enclosing_Instance.strict;
			}
Exemplo n.º 11
0
 public AnonymousCustomScoreProvider(CustomScoreQuery parent, IndexReader reader) : base(reader)
 {
     this.parent = parent;
 }