Improve search precision
This commit is contained in:
parent
16f25f56ca
commit
e615962275
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue