-
Notifications
You must be signed in to change notification settings - Fork 27
/
documents.py
60 lines (52 loc) · 1.28 KB
/
documents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from elasticsearch_dsl import Document
REPO_INDEXES = ['sources', 'collections']
class RepoDocument(Document):
multi_index = True
indexes = REPO_INDEXES
class Meta:
index = REPO_INDEXES
@staticmethod
def get_match_phrase_attrs():
return ['name', 'external_id', 'canonical_url']
@staticmethod
def get_exact_match_attrs():
return {
'mnemonic': {
'boost': 4,
},
'name': {
'boost': 3.5,
},
'canonical_url': {
'boost': 3,
},
'external_id': {
'boost': 2.5
}
}
@staticmethod
def get_wildcard_search_attrs():
return {
'mnemonic': {
'boost': 1,
'lower': True,
'wildcard': True
},
'name': {
'boost': 0.8,
'lower': True,
'wildcard': True
},
'canonical_url': {
'boost': 0.6,
'lower': True,
'wildcard': True
}
}
@staticmethod
def get_fuzzy_search_attrs():
return {
'name': {
'boost': 0.8,
},
}