/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using IndexReader = Lucene.Net.Index.IndexReader; using TermDocs = Lucene.Net.Index.TermDocs; using ToStringUtils = Lucene.Net.Util.ToStringUtils; using Lucene.Net.Search; namespace Lucene.Net.Search.Function { /// Expert: A Query that sets the scores of document to the /// values obtained from a ValueSource. ///

/// This query provides a score for each and every undeleted document in the index. ///

/// The value source can be based on a (cached) value of an indexed field, but it /// can also be based on an external source, e.g. values read from an external database. ///

/// Score is set as: Score(doc,query) = query.getBoost()2 * valueSource(doc). /// ///

/// WARNING: The status of the Search.Function package is experimental. /// The APIs introduced here might change in the future and will not be /// supported anymore in such a case. ///

[Serializable] public class ValueSourceQuery:Query { internal ValueSource valSrc; /// Create a value source query /// provides the values defines the function to be used for scoring /// public ValueSourceQuery(ValueSource valSrc) { this.valSrc = valSrc; } /*(non-Javadoc) instead. /// [Obsolete("use NextDoc() instead. ")] public override bool Next() { return termDocs.Next(); } public override int NextDoc() { return doc = termDocs.Next()?termDocs.Doc():NO_MORE_DOCS; } /// use instead. /// [Obsolete("use DocID() instead.")] public override int Doc() { return termDocs.Doc(); } public override int DocID() { return doc; } /*(non-Javadoc) instead. /// [Obsolete("use Advance(int)} instead.")] public override bool SkipTo(int target) { return termDocs.SkipTo(target); } public override int Advance(int target) { return doc = termDocs.SkipTo(target)?termDocs.Doc():NO_MORE_DOCS; } /*(non-Javadoc) Returns true if o is equal to this. public override bool Equals(System.Object o) { if (GetType() != o.GetType()) { return false; } ValueSourceQuery other = (ValueSourceQuery) o; return this.GetBoost() == other.GetBoost() && this.valSrc.Equals(other.valSrc); } /// Returns a hash code value for this object. public override int GetHashCode() { return (GetType().GetHashCode() + valSrc.GetHashCode()) ^ BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0); } override public System.Object Clone() { return this.MemberwiseClone(); } public ValueSource valSrc_ForNUnit { get { return valSrc; } } } }