Better query fuzziness

This commit is contained in:
Chocobozzz 2020-09-23 10:35:23 +02:00
parent a5776c596e
commit e586067521
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 10 additions and 6 deletions

View File

@ -71,6 +71,10 @@ const REQUESTS = {
WAIT: 10000 // 10 seconds
}
const ELASTIC_SEARCH_QUERY = {
FUZZINESS: 'AUTO:4,7'
}
function getWebserverUrl () {
if (CONFIG.WEBSERVER.PORT === 80 || CONFIG.WEBSERVER.PORT === 443) {
return CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME
@ -94,5 +98,6 @@ export {
SCHEDULER_INTERVALS_MS,
INDEXER_CONCURRENCY,
INDEXER_COUNT,
REQUESTS
REQUESTS,
ELASTIC_SEARCH_QUERY
}

View File

@ -1,8 +1,7 @@
import { difference } from 'lodash'
import { buildIndex, buildSort, elasticSearch, extractQueryResult, indexDocuments } from '../helpers/elastic-search'
import { logger } from '../helpers/logger'
import { CONFIG } from '../initializers/constants'
import { CONFIG, ELASTIC_SEARCH_QUERY } from '../initializers/constants'
import { ChannelsSearchQuery } from '../types/channel-search.model'
import { DBChannel, EnhancedVideoChannel, IndexableChannel } from '../types/channel.model'
import { buildAvatarMapping, formatAvatarForAPI, formatAvatarForDB } from './elastic-search-avatar'
@ -86,7 +85,7 @@ async function queryChannels (search: ChannelsSearchQuery) {
multi_match: {
query: search.search,
fields: [ 'name^5', 'displayName^3', 'description' ],
fuzziness: 'AUTO'
fuzziness: ELASTIC_SEARCH_QUERY.FUZZINESS
}
}
]

View File

@ -2,7 +2,7 @@ import { difference } from 'lodash'
import { buildIndex, buildSort, elasticSearch, extractQueryResult, indexDocuments } from '../helpers/elastic-search'
import { logger } from '../helpers/logger'
import { buildUrl } from '../helpers/utils'
import { CONFIG } from '../initializers/constants'
import { CONFIG, ELASTIC_SEARCH_QUERY } from '../initializers/constants'
import { VideosSearchQuery } from '../types/video-search.model'
import { DBVideo, DBVideoDetails, EnhancedVideo, IndexableVideo, IndexableVideoDetails } from '../types/video.model'
import { buildAvatarMapping, formatAvatarForAPI, formatAvatarForDB } from './elastic-search-avatar'
@ -117,7 +117,7 @@ async function queryVideos (search: VideosSearchQuery) {
multi_match: {
query: search.search,
fields: [ 'name^5', 'description', 'tags^3' ],
fuzziness: 'AUTO'
fuzziness: ELASTIC_SEARCH_QUERY.FUZZINESS
}
}
]