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;

/** Execute searches against a single index.
 *
 * Use the IndexSearcher class to perform search queries against an index.
 * (For searching multiple indexes at once, see
 * [](cfish:PolySearcher)).
 *
 * IndexSearchers operate against a single point-in-time view or
 * [](cfish:Snapshot) of the index.  If an index is
 * modified, a new IndexSearcher must be opened to access the changes.
 */
public class Lucy::Search::IndexSearcher nickname IxSearcher
    inherits Lucy::Search::Searcher {

    IndexReader       *reader;
    DocReader         *doc_reader;
    HighlightReader   *hl_reader;
    Vector            *seg_readers;
    I32Array          *seg_starts;

    /** Create a new IndexSearcher.
     *
     * @param index Either a string filepath, a Folder, or an IndexReader.
     */
    public inert incremented IndexSearcher*
    new(Obj *index);

    /** Initialize an IndexSearcher.
     *
     * @param index Either a string filepath, a Folder, or an IndexReader.
     */
    public inert IndexSearcher*
    init(IndexSearcher *self, Obj *index);

    public void
    Destroy(IndexSearcher *self);

    public int32_t
    Doc_Max(IndexSearcher *self);

    public uint32_t
    Doc_Freq(IndexSearcher *self, String *field, Obj *term);

    public void
    Collect(IndexSearcher *self, Query *query, Collector *collector);

    incremented TopDocs*
    Top_Docs(IndexSearcher *self, Query *query, uint32_t num_wanted,
             SortSpec *sort_spec = NULL);

    public incremented HitDoc*
    Fetch_Doc(IndexSearcher *self, int32_t doc_id);

    incremented DocVector*
    Fetch_Doc_Vec(IndexSearcher *self, int32_t doc_id);

    /** Accessor for the object's `reader` member.
     */
    public IndexReader*
    Get_Reader(IndexSearcher *self);

    void
    Close(IndexSearcher *self);
}