Hi @matthewb,
Thanks for your return.
I want to use the added field just to filter the search, there will be joins to select actors, categories, tags, etc.
The goal is to speed up the search while filtering several entities
An example query would be:
SELECT
Videos.id AS Videos__id,
Videos.title AS Videos__title,
...
FROM
videos Videos
LEFT JOIN videos_translations VideosTranslation ON (
VideosTranslation.locale = 'fr'
AND Videos.id = VideosTranslation.id
)
WHERE
(
Videos.active = TRUE
AND Videos.segment = 1
AND (Videos.deleted) IS NULL
AND MATCH(
Videos.properties
) AGAINST(
'my search' IN NATURAL LANGUAGE MODE
)
)
ORDER BY
Videos.views DESC
LIMIT
40 OFFSET 0
Here is part of the current database schema:
-- -----------------------------------------------------
-- videos
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `videos` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`producer_id` INT UNSIGNED NULL,
`title` VARCHAR(120) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
FULLTEXT INDEX `title` (`title`) VISIBLE,
INDEX `producer_id_INDEX` (`producer_id` ASC) VISIBLE
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `videos_translations` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`locale` CHAR(2) NOT NULL,
`title` VARCHAR(120) NOT NULL,
PRIMARY KEY (`id`, `locale`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- categories
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `categories` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `name` (`name` ASC) VISIBLE
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `categories_translations` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`locale` CHAR(2) NOT NULL,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`, `locale`),
UNIQUE INDEX `name` (`locale` ASC, `name` ASC) VISIBLE)
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `categories_videos` (
`video_id` INT UNSIGNED NOT NULL,
`category_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`video_id`, `category_id`),
INDEX `category_video_INDEX` (`category_id` ASC, `video_id` ASC) VISIBLE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- producers
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `producers` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `name` (`name` ASC) VISIBLE
ENGINE = InnoDB;
-- -----------------------------------------------------
-- actors
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `actors` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `name` (`name` ASC) VISIBLE
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `actors_videos` (
`video_id` INT UNSIGNED NOT NULL,
`actor_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`video_id`, `actor_id`),
INDEX `actor_video_INDEX` (`actor_id` ASC, `video_id` ASC) VISIBLE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- tags
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tags` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `name` (`name` ASC) VISIBLE
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `tags_translations` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`locale` CHAR(2) NOT NULL,
`name` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`id`, `locale`))
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `tags_videos` (
`video_id` INT UNSIGNED NOT NULL,
`tag_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`video_id`, `tag_id`),
INDEX `tag_video_INDEX` (`tag_id` ASC, `video_id` ASC) VISIBLE)
ENGINE = InnoDB;