The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
/* 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.
 */

parcel Lucy;


/** Query which matches individual terms.
 *
 * TermQuery is a subclass of [](cfish:Query) for matching
 * individual terms in a specific field.
 */

public class Lucy::Search::TermQuery inherits Lucy::Search::Query {

    String *field;
    Obj    *term;

    /** Create a new TermQuery.
     *
     * @param field Field name.
     * @param term Term text.
     */
    public inert incremented TermQuery*
    new(String *field, Obj *term);

    /** Initialize a TermQuery.
     *
     * @param field Field name.
     * @param term Term text.
     */
    public inert TermQuery*
    init(TermQuery *self, String *field, Obj *term);

    /** Accessor for object's `field` member.
     */
    public String*
    Get_Field(TermQuery *self);

    /** Accessor for object's `term` member.
     */
    public Obj*
    Get_Term(TermQuery *self);

    public incremented Compiler*
    Make_Compiler(TermQuery *self, Searcher *searcher, float boost,
                  bool subordinate = false);

    public incremented String*
    To_String(TermQuery *self);

    void
    Serialize(TermQuery *self, OutStream *outstream);

    incremented TermQuery*
    Deserialize(decremented TermQuery *self, InStream *instream);

    public incremented Obj*
    Dump(TermQuery *self);

    public incremented Obj*
    Load(TermQuery *self, Obj *dump);

    public bool
    Equals(TermQuery *self, Obj *other);

    public void
    Destroy(TermQuery *self);
}

class Lucy::Search::TermCompiler inherits Lucy::Search::Compiler {
    float idf;
    float raw_weight;
    float query_norm_factor;
    float normalized_weight;

    inert incremented TermCompiler*
    new(Query *parent, Searcher *searcher, float boost);

    inert TermCompiler*
    init(TermCompiler *self, Query *parent, Searcher *searcher,
         float boost);

    public incremented nullable Matcher*
    Make_Matcher(TermCompiler *self, SegReader *reader, bool need_score);

    public float
    Get_Weight(TermCompiler *self);

    public float
    Sum_Of_Squared_Weights(TermCompiler *self);

    public void
    Apply_Norm_Factor(TermCompiler *self, float factor);

    incremented Vector*
    Highlight_Spans(TermCompiler *self, Searcher *searcher,
                    DocVector *doc_vec, String *field);

    public bool
    Equals(TermCompiler *self, Obj *other);

    void
    Serialize(TermCompiler *self, OutStream *outstream);

    incremented TermCompiler*
    Deserialize(decremented TermCompiler *self, InStream *instream);
}