liveBook · Manning

Collection

As explained in AI-Powered Search

A collection is a logical search-engine unit that contains a schema and configuration and holds indexed documents for searching and retrieval.

A collection is a search-engine unit with its own schema and configuration. Documents are indexed into it; queries use it to search, rank, and retrieve results. Create the collection before loading documents, then search the fields relevant to the task. section 3.2.1 section 13.4.1

Create, index, and search

A small text-ranking test creates a collection, adds documents with id, title, and description fields, then searches description for “the cat in the hat.” Requesting score and an explanation makes the BM25 ranking inspectable. In Python, the sequence is engine.create_collection("cat_in_the_hat"), collection.add_documents(docs), then collection.search(**request). section 3.2.1

A collection’s fields reflect its job. An outdoors collection holds both questions and answers: post_type distinguishes them, parent_id links answers to questions, and accepted_answer_id identifies a selected answer. A search can restrict results to questions while querying title and body. Metadata such as view_count is also available as a potential relevance signal. section 13.4.1

A separate entities collection serves query interpretation rather than ordinary result retrieval. It stores surface forms to match in incoming queries, canonical forms to normalize them, types, and popularity values that help choose among ambiguous matches. Its Solr text-tagger configuration supports fast entity extraction; the resulting matches can be assembled into a typed query tree. section 7.4.1

Listing 13.1 Indexing the outdoors dataset
outdoors_collection = engine.create_collection("outdoors")
outdoors_dataframe = load_outdoors_data("data/outdoors/posts.csv")
outdoors_collection.write(outdoors_dataframe)

The Python listing shows the collection lifecycle in one place: create the outdoors collection, load post data, and write it for indexing. section 13.4.1

How AI-Powered Search covers it

How deep it goes
Defines the unit and works through creation, indexing, and searches, with a specialized Solr configuration example.
Examples
Uses a three-document BM25 test, linked outdoor questions and answers, and an entities lookup for query parsing.
What it assumes
Assumes basic Python and search-query familiarity while showing collection creation, document loading, and search requests.
What you can do after
Operate/configure it by creating a collection, loading documents, and searching selected fields or extracting query entities.
How it connects
Connects collections to schemas, indexed documents, BM25 ranking, lexical search, and entity extraction.

Also explained in

Compare how 16 books explain collection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI-Powered Search. The section links point to the parts of the book it draws on.