SearchService.h header

#include <ew/app/SearchService.h>

Namespace ew::app

Entry struct

struct ew::app::Entry

One object as the search sees it: its identity, its title, and the text to match against.

Members

ew::core::foundation::ContentId ew::app::search::SearchService::Entry::id

The object's id, returned with a result so the caller can navigate to it.

QString ew::app::search::SearchService::Entry::title

The object's display title.

QString ew::app::search::SearchService::Entry::body

The text a search matches against: a document's prose (markup removed for a legacy rich-text body) or an entity's field values and aliases.

bool ew::app::search::SearchService::Entry::isDocument = false

True when the object is a document, so a scope filter needs no second dynamic_cast.

bool ew::app::search::SearchService::Entry::isEntity = false

True when the object is an entity, for the same reason.

SearchResult struct

struct ew::app::SearchResult

One hit from a project search: the object found, a display title, a short matching snippet, and a relevance score (higher is more relevant).

Members

ew::core::foundation::ContentId ew::app::search::SearchResult::id

The content object that matched.

QString ew::app::search::SearchResult::title

The object's display title (a document title or an entity name).

QString ew::app::search::SearchResult::snippet

A short excerpt of the body around the first matched term.

int ew::app::search::SearchResult::score = 0

Relevance score; results are returned in descending score order.

SearchService class

class ew::app::SearchService

Full-text search over a project's content. It scans documents (title and body) and entities (name and field values) for the query terms, ranks title matches above body matches, and boosts titles that begin with the query. This in-memory scan is the first step; a derived FTS index can back the same interface later for large projects.

Members

ew::app::search::SearchService::SearchService(const ew::core::project::Project &project)

Searches project alone (no mounted libraries); not owned.

ew::app::search::SearchService::SearchService(const ew::core::project::Project &project, const app::library::MountedLibraries &libraries)

Searches project and every library it mounts, so results span the whole working graph (shared universes / reference libraries included). Neither is owned.

void ew::app::search::SearchService::rebuild()

Rebuilds the searchable snapshot from the current project state.

The snapshot is built lazily on the first search and then reused, because a search runs once per keystroke while deriving each object's searchable text is not free – reducing a legacy rich-text body to its prose costs an HTML parse, measured at ~25 s across 100 legacy chapters, which per keystroke would be unusable (F-0096). Call this after the project changes; a service that lives only for one interaction never needs to.

Enumerations

enum class SearchScope { Everything, Documents, Entities }

Which kinds of object a search covers (a search facet).