This project has retired. For details please refer to its Attic page.
Lucy::Search::IndexSearcher – C API Documentation
Apache Lucy™

Lucy::Search::IndexSearcher

parcel Lucy
class variable LUCY_INDEXSEARCHER
struct symbol lucy_IndexSearcher
class nickname lucy_IxSearcher
header file Lucy/Search/IndexSearcher.h

Name

Lucy::Search::IndexSearcher – Execute searches against a single index.

Description

Use the IndexSearcher class to perform search queries against an index. (For searching multiple indexes at once, see PolySearcher).

IndexSearchers operate against a single point-in-time view or Snapshot of the index. If an index is modified, a new IndexSearcher must be opened to access the changes.

Functions

new
lucy_IndexSearcher* // incremented
lucy_IxSearcher_new(
    cfish_Obj *index
);

Create a new IndexSearcher.

index

Either a string filepath, a Folder, or an IndexReader.

init
lucy_IndexSearcher*
lucy_IxSearcher_init(
    lucy_IndexSearcher *self,
    cfish_Obj *index
);

Initialize an IndexSearcher.

index

Either a string filepath, a Folder, or an IndexReader.

Methods

Doc_Max
int32_t
lucy_IxSearcher_Doc_Max(
    lucy_IndexSearcher *self
);

Return the maximum number of docs in the collection represented by the Searcher, which is also the highest possible internal doc id. Documents which have been marked as deleted but not yet purged are included in this count.

Doc_Freq
uint32_t
lucy_IxSearcher_Doc_Freq(
    lucy_IndexSearcher *self,
    cfish_String *field,
    cfish_Obj *term
);

Return the number of documents which contain the term in the given field.

field

Field name.

term

The term to look up.

Collect
void
lucy_IxSearcher_Collect(
    lucy_IndexSearcher *self,
    lucy_Query *query,
    lucy_Collector *collector
);

Iterate over hits, feeding them into a Collector.

query

A Query.

collector

A Collector.

Fetch_Doc
lucy_HitDoc* // incremented
lucy_IxSearcher_Fetch_Doc(
    lucy_IndexSearcher *self,
    int32_t doc_id
);

Retrieve a document. Throws an error if the doc id is out of range.

doc_id

A document id.

Get_Reader
lucy_IndexReader*
lucy_IxSearcher_Get_Reader(
    lucy_IndexSearcher *self
);

Accessor for the object’s reader member.

Methods inherited from Lucy::Search::Searcher

Glean_Query
lucy_Query* // incremented
lucy_IxSearcher_Glean_Query(
    lucy_IndexSearcher *self,
    cfish_Obj *query
);

If the supplied object is a Query, return it; if it’s a query string, create a QueryParser and parse it to produce a query against all indexed fields.

Hits
lucy_Hits* // incremented
lucy_IxSearcher_Hits(
    lucy_IndexSearcher *self,
    cfish_Obj *query,
    uint32_t offset,
    uint32_t num_wanted,
    lucy_SortSpec *sort_spec
);

Return a Hits object containing the top results.

query

Either a Query object or a query string.

offset

The number of most-relevant hits to discard, typically used when “paging” through hits N at a time. Setting offset to 20 and num_wanted to 10 retrieves hits 21-30, assuming that 30 hits can be found.

num_wanted

The number of hits you would like to see after offset is taken into account.

sort_spec

A SortSpec, which will affect how results are ranked and returned.

Get_Schema
lucy_Schema*
lucy_IxSearcher_Get_Schema(
    lucy_IndexSearcher *self
);

Accessor for the object’s schema member.

Inheritance

Lucy::Search::IndexSearcher is a Lucy::Search::Searcher is a Clownfish::Obj.