mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 09:30:01 +00:00
[ES Schema change] Multi-field search display_name to match words over ngram limit
This fixes searching for "Machiavellianism", 16 chars ("Machiavellianis", 15 chars, worked previously). Does not (seem to!) break anything, but requires a re-indexing of ES.
This commit is contained in:
parent
ae71b6ed59
commit
2d0cf7cbb4
|
@ -23,6 +23,17 @@ settings:
|
||||||
- my_ngram
|
- my_ngram
|
||||||
- word_delimit
|
- word_delimit
|
||||||
- trim_zero
|
- trim_zero
|
||||||
|
# For matching full words longer than the ngram limit (15 chars)
|
||||||
|
my_fullword_index_analyzer:
|
||||||
|
type: custom
|
||||||
|
tokenizer: standard
|
||||||
|
char_filter:
|
||||||
|
- my_char_filter
|
||||||
|
filter:
|
||||||
|
- lowercase
|
||||||
|
- word_delimit
|
||||||
|
# These should be enough, as my_index_analyzer will match the rest
|
||||||
|
|
||||||
filter:
|
filter:
|
||||||
my_ngram:
|
my_ngram:
|
||||||
type: edgeNGram
|
type: edgeNGram
|
||||||
|
@ -67,7 +78,13 @@ mappings:
|
||||||
# the scene convention of stuff in brackets, plus stuff like k-on
|
# the scene convention of stuff in brackets, plus stuff like k-on
|
||||||
type: text
|
type: text
|
||||||
analyzer: my_index_analyzer
|
analyzer: my_index_analyzer
|
||||||
fielddata: true
|
fielddata: true # Is this required?
|
||||||
|
fields:
|
||||||
|
# Multi-field for full-word matching (when going over ngram limits)
|
||||||
|
# Note: will have to be queried for, not automatic
|
||||||
|
fullword:
|
||||||
|
type: text
|
||||||
|
analyzer: my_fullword_index_analyzer
|
||||||
created_time:
|
created_time:
|
||||||
type: date
|
type: date
|
||||||
# Only in the ES index for generating magnet links
|
# Only in the ES index for generating magnet links
|
||||||
|
|
|
@ -109,6 +109,8 @@ def search_elastic(term='', user=None, sort='id', order='desc',
|
||||||
# Apply search term
|
# Apply search term
|
||||||
if term:
|
if term:
|
||||||
s = s.query('simple_query_string',
|
s = s.query('simple_query_string',
|
||||||
|
# Query both fields, latter for words with >15 chars
|
||||||
|
fields=['display_name', 'display_name.fullword'],
|
||||||
analyzer='my_search_analyzer',
|
analyzer='my_search_analyzer',
|
||||||
default_operator="AND",
|
default_operator="AND",
|
||||||
query=term)
|
query=term)
|
||||||
|
|
Loading…
Reference in a new issue