Smart search – additional module Smarty smart search base Manticore Search, which allows you to replace the usual search for films by substring in the title with a full-text search for different fields of the film:
- smart search forgives typos (which is especially useful for voice input);
- movies are searched for genres, actors and other meta;
- search results are less likely to yield empty results — more content options are offered to the subscriber;
- smart search faster than usual 🙂
Technical details of smart search
- available starting with Smarty 2.12;
- it works through a separate Manticore index, rather than through SQL search for the main database;
- searches immediately by name, genres, actors and directors, year and countries;
- sorts the output by relevance within Manticore: coincidence in the name is more important than secondary fields, the coincidence at the beginning of the name rises higher;
- takes into account word forms and prefix (the search works from one character);
- there is a tool for debunking why the film was released: parameter
searchreturns coincidence highlighting and relevance weight; - does not use built-in search options
TVMW USE UNACCENT SEARCHandTVMW_VIDEO_LIST_SEARCH_BY_RELEVANCEthey do not affect smart search; - it is connected by a separate Smarty license option and requires Manticore installed plus regular index synchronization.
How to set up
1 Updating the Smarty license key
Example of license fragment:
SMARTY_LICENSE_PARAMS = {
...
'smart search',
...
}2 Manticore installation
Manticore can be installed on the same server as Smarty, or on a separate host. By default, Smarty connects to localhost: 9306 (MySQL Manticore Protocol).
Debian/Ubuntu:
wget https://repo.manticoresearch.com/manticore-repo.noarch.deb sudo dpkg -i manticore-repo.noarch.deb sudo apt update sudo apt install manticore sudo systemctl enable manticore sudo systemctl start manticore
Other OSs in manticore documentation. If it has not been changed after installation /etc/manticoresearch/manticore.conf, default MANTICORE HOST and MANTICORE PORT smarty will do.
Check that the service listens to the port:
mysql -h0 - P9306
3 Smarty settings
Options are set in the Smarty configuration file /etc/microimpuls/smarty/smarty.py (or in the custom configuration file). After the change, restart uwsgi: sudo service uwsgi restart.
The module should be included in INSTALLED_APPS:
INSTALLED APPS += 'smart search', )
Connection to Manticore:
MANTICORE HOSTThe address of the Manticore Search host. Data type: string. By default localhost.MANTICORE PORTPort of connection to Manticore Search. Data type: int. By default 9306.
Example of settings:
Manticore host = 'localhost' Manticore PORT = 9306
To connect to Manticore on the Smarty server, you need a library pymysql. When commands are started, they appear No module named 'pymysql':
smarty manage pip install pymysql==1.0.2 --settings=settings.
Index synchronization commands
The index in Manticore does not update itself when the video library changes. First, the table diagram is updated, then the catalog data.
Synchronization of the scheme
Team:
smarty manage manticore sync database --settings=settings.
Creates module tables in Manticore smart search update their structure if necessary. A table is created for the video tvmiddleware video:
id- string identifier in Manticore;name- name;actorsactors and directors by comma;genres- genres by comma;year- year of release;countries- countries;client- Client ID in Smarty;smart id- Video ID in Smarty.
It is enough to run the command after the Smarty update if the index scheme has changed.
Synchronization of the video catalog
Team:
smarty manage manticore sync content --settings=settings.
Records in Manticore data about movies in Smarty and updates already indexed records. Run regularly - with the frequency with which the video library changes movies. Without the current scheme, the team will not work.
Mandatory parameters:
-client_id Client identifier whose directory is synchronized.
Optional parameters:
-create chunk size Maximum strings added to Manticore per request. Default 50.
-delete_chunk_size The maximum number of lines removed from Manticore per request. Default 50.
--force full sync Complete re-indexing: tables are cleaned, the catalog is imported as a whole. It is necessary after changing the index scheme or if the issuance is very different from the video library.
Example of the first download and subsequent updates:
smarty manage manticore sync database --settings=settings. smarty manage manticore sync content --client id=1 --settings=settings;
After the Smarty update, which changes the index structure:
smarty manage manticore sync database --settings=settings. smarty manage manticore sync content --client id=1 --force full sync --settings=settings;
Client applications
Smart search is already integrated in the Titanium TV interface and mobile application, enabled by the option use smart video search.
