Search Engine
Here you can explore the search implementation I provide. This search is created using the Sphinx Search Server. You can try to find a book by its title, author, or headline, as well as insert an excerpt from the text. Please note that this is just a demonstration of the capabilities I can offer you. Contact me to learn about other services and solutions for your project. The database contains over 7000 books. All texts are public domain and sourced from Project Gutenberg.
Demo
You can try out this search.
For convenience of implementation, an API was developed using FastAPI, the documentation of which can be viewed at the following link or you can try via docs.
Search Mechanism
Indexing. At this stage, data from the original documents (such as a database or files) is transformed into a Sphinx index. The index is a binary file where data is stored in a compressed and optimized format for quick retrieval.
Searching. At this stage, the system searches for documents containing the specified search phrase. Sphinx employs full-text search, allowing users to search not only by keywords but also by phrases, combinations of words, and even word morphology.
Search Results. Sphinx returns a list of documents that contain the specified search phrase. The list of documents is sorted by relevance, meaning the degree of correspondence to the search phrase.
Data from the original documents undergoes conversion into a format suitable for storage in the Sphinx index. Specialized modules are employed for this purpose, supporting various data types such as text documents, image files, databases, and so forth. Transformed data is written into the Sphinx index. The index can be created in one of two modes:
- Real-time Indexing: In this mode, the index is created concurrently with changes to the original data.
- Background Indexing: In this mode, the index is created periodically, for example, once a day or once a week.
Works with Databases
Demo Database
Below is a PostgreSQL database table used for creating this demo. Here, you can see a fairly standard table containing a field with text (the entire book) for full-text search, as well as a title and author. Searches are also conducted based on the author and title.
CREATE TABLE IF NOT EXISTS public.books
(
item_id integer NOT NULL DEFAULT nextval('books_item_id_seq'::regclass),
title character varying(150) COLLATE pg_catalog."default",
author character varying(100) COLLATE pg_catalog."default",
url character varying(100) COLLATE pg_catalog."default",
book_shelf character varying(50) COLLATE pg_catalog."default",
text text COLLATE pg_catalog."default",
CONSTRAINT books_pkey PRIMARY KEY (item_id)
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.books
OWNER to "user";