Improve search precision

This commit is contained in:
Chocobozzz 2021-11-23 17:07:59 +01:00
parent 16f25f56ca
commit e615962275
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 12 additions and 6 deletions

View File

@ -147,7 +147,9 @@ const REQUESTS = {
const ELASTIC_SEARCH_QUERY = {
FUZZINESS: 'AUTO:4,7',
BOOST_LANGUAGE_VALUE: 2,
OPERATOR: 'AND',
BOOST_LANGUAGE_VALUE: 1,
MALUS_LANGUAGE_VALUE: 0.5,
VIDEOS_MULTI_MATCH_FIELDS: buildMultiMatchFields(CONFIG.VIDEOS_SEARCH.SEARCH_FIELDS),
CHANNELS_MULTI_MATCH_FIELDS: buildMultiMatchFields(CONFIG.CHANNELS_SEARCH.SEARCH_FIELDS),
PLAYLISTS_MULTI_MATCH_FIELDS: buildMultiMatchFields(CONFIG.PLAYLISTS_SEARCH.SEARCH_FIELDS)

View File

@ -20,7 +20,8 @@ async function queryChannels (search: ChannelsSearchQuery) {
multi_match: {
query: search.search,
fields: ELASTIC_SEARCH_QUERY.CHANNELS_MULTI_MATCH_FIELDS,
fuzziness: ELASTIC_SEARCH_QUERY.FUZZINESS
fuzziness: ELASTIC_SEARCH_QUERY.FUZZINESS,
operator: ELASTIC_SEARCH_QUERY.OPERATOR
}
}
]

View File

@ -20,7 +20,8 @@ async function queryPlaylists (search: PlaylistsSearchQuery) {
multi_match: {
query: search.search,
fields: ELASTIC_SEARCH_QUERY.PLAYLISTS_MULTI_MATCH_FIELDS,
fuzziness: ELASTIC_SEARCH_QUERY.FUZZINESS
fuzziness: ELASTIC_SEARCH_QUERY.FUZZINESS,
operator: ELASTIC_SEARCH_QUERY.OPERATOR
}
}
]

View File

@ -22,7 +22,8 @@ async function queryVideos (search: VideosSearchQuery) {
multi_match: {
query: search.search,
fields: ELASTIC_SEARCH_QUERY.VIDEOS_MULTI_MATCH_FIELDS,
fuzziness: ELASTIC_SEARCH_QUERY.FUZZINESS
fuzziness: ELASTIC_SEARCH_QUERY.FUZZINESS,
operator: ELASTIC_SEARCH_QUERY.OPERATOR
}
}
]
@ -204,7 +205,7 @@ async function queryVideos (search: VideosSearchQuery) {
if (docLang == language) return _score * params.boost;
}
return _score;
return _score * params.malus;
`
Object.assign(body, {
@ -215,7 +216,8 @@ async function queryVideos (search: VideosSearchQuery) {
source: boostScript,
params: {
boostLanguages: search.boostLanguages,
boost: ELASTIC_SEARCH_QUERY.BOOST_LANGUAGE_VALUE
boost: ELASTIC_SEARCH_QUERY.BOOST_LANGUAGE_VALUE,
malus: ELASTIC_SEARCH_QUERY.MALUS_LANGUAGE_VALUE
}
}
}