-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearchConfiguration.js
337 lines (334 loc) · 10.6 KB
/
searchConfiguration.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
var searchStyle = {
inputWrapper: {
"position": "absolute",
"height": "100%",
"width": "100%",
"top": "10%"
},
searchText: {
"width": "100vh",
"zIndex": "6",
"fontSize": "22px",
"color": "black",
"backgroundColor": "white",
"padding": "7px 20px 7px 20px",
"border": "3px solid #11bffe",
},
filterIcon: {
"right": "25px",
"bottom": "15px",
"zIndex": "6",
"cursor": "pointer",
"fontSize": "25px",
"position": "absolute",
"color": "black",
},
closeIcon: {
"position": "relative",
"color": "#11bffe",
"bottom": "50px",
"right": "14px",
"fontWeight": "bold",
"fontSize": "20px",
"cursor": "pointer",
},
paperResults: {
"left": "14%",
"height": "50%",
"width": "70%",
"position": "absolute",
"textAlign": "center",
"backgroundColor": "#333333",
"padding": "12px 20px 12px 20px",
"overflow": "scroll",
"zIndex": "5",
},
paperFilters: {
"minHeight": "280px",
"minWidth": "240px",
"position": "absolute",
"backgroundColor": "#141313",
"color": "white",
"overflow": "scroll",
"zIndex": "6",
"border": "3px solid #11bffe",
"fontFamily": "Barlow, Khand, sans-serif",
"fontSize": "16px",
"top": "58px",
"right": "0px",
},
singleResult: {
"color": "white",
"fontSize": "18px",
"whiteSpace" : "normal",
":hover": {
"color": "#11bffe",
"background-color": "#252323",
},
},
main: {
"position": "absolute",
"top": "0px",
"left": "0px",
"width": "100%",
"height": "100%",
"margin": "0",
"padding": "0",
"zIndex": "3",
"backgroundColor": "rgba(51, 51, 51, 0.7)",
"textAlign": "center",
"display": "flex",
"alignItems": "center",
"justifyContent": "center",
}
};
var datasourceConfiguration = {
"url": "https://solr.virtualflybrain.org/solr/ontology/select",
"query_settings":
{
"q": "$SEARCH_TERM$ OR $SEARCH_TERM$* OR *$SEARCH_TERM$*",
"defType": "edismax",
"qf": "label^100 synonym^100 label_autosuggest_ws label_autosuggest_e label_autosuggest synonym_autosuggest_ws synonym_autosuggest shortform_autosuggest",
"indent": "true",
"fl": "short_form,label,synonym,id,facets_annotation",
"start": "0",
"pf":"true",
"fq": [
"shortform_autosuggest:VFB* OR shortform_autosuggest:FB* OR facets_annotation:DataSet OR facets_annotation:pub"
],
"rows": "100",
"wt": "json",
"bq": "shortform_autosuggest:VFB*^110.0 shortform_autosuggest:FBbt*^100.0 label_s:\"\"^2 synonym_s:\"\" short_form:FBbt_00003982^2 facets_annotation:Deprecated^0.001"
}
};
var searchConfiguration = {
"resultsMapping":
{
"name": "label",
"id": "short_form",
"labels" : "facets_annotation"
},
"label_manipulation" : label => label,
"filters_expanded": true,
"filter_positive" : "^100",
"filter_negative" : "^0.001",
"filters": [
{
"key": "facets_annotation",
"filter_name": "Filters",
"type": "array",
"enabled": "disabled",
"disableGlobal": true,
"values": [
{
"key": "Adult",
"filter_name": "Adult",
"enabled": "disabled",
},
{
"key": "Larva",
"filter_name": "Larva",
"enabled": "disabled",
},
{
"key": "Nervous_system",
"filter_name": "Nervous System",
"enabled": "disabled",
},
{
"key": "Anatomy",
"filter_name": "Anatomy",
"enabled": "disabled",
},
{
"key": "Neuron",
"filter_name": "Neuron",
"enabled": "disabled",
},
{
"key": "has_image",
"filter_name": "Image",
"enabled": "disabled",
},
{
"key": "Split",
"filter_name": "Split Expression",
"enabled": "disabled",
},
{
"key": "Expression_pattern",
"filter_name": "Expression Pattern",
"enabled": "disabled",
},
{
"key": "Expression_pattern_fragment",
"filter_name": "Expression Pattern Fragment",
"enabled": "disabled",
},
{
"key": "has_neuron_connectivity",
"filter_name": "Neuron with Connectivity",
"enabled": "disabled",
},
{
"key": "NBLAST",
"filter_name": "Neuron Similarity (NBLAST)",
"enabled": "disabled",
},
{
"key": "NBLASTexp",
"filter_name": "Expression Similarity (NBLAST)",
"enabled": "disabled",
},
{
"key": "Synaptic_neuropil_domain",
"filter_name": "Synaptic Neuropil",
"enabled": "disabled",
},
{
"key": "DataSet",
"filter_name": "Dataset",
"enabled": "disabled",
},
{
"key": "Deprecated",
"filter_name": "Deprecated",
"enabled": "negative",
}
]
},
],
"sorter": function (a, b) {
var InputString = window.spotlightString;
// move exact matches to top
if (InputString == a.label) {
return -1;
}
if (InputString == b.label) {
return 1;
}
// close match without case matching
if (InputString.toLowerCase() == a.label.toLowerCase()) {
return -1;
}
if (InputString.toLowerCase() == b.label.toLowerCase()) {
return 1;
}
// match ignoring joinging nonwords
if (InputString.toLowerCase().split(/\W+/).join(' ') == a.label.toLowerCase().split(/\W+/).join(' ')) {
return -1;
}
if (InputString.toLowerCase().split(/\W+/).join(' ') == b.label.toLowerCase().split(/\W+/).join(' ')) {
return 1;
}
// match against id
if (InputString.toLowerCase() == a.id.toLowerCase()) {
return -1;
}
if (InputString.toLowerCase() == b.id.toLowerCase()) {
return 1;
}
// pick up any match without nonword join character match
if (a.label.toLowerCase().split(/\W+/).join(' ').indexOf(InputString.toLowerCase().split(/\W+/).join(' ')) < 0 && b.label.toLowerCase().split(/\W+/).join(' ').indexOf(InputString.toLowerCase().split(/\W+/).join(' ')) > -1) {
return 1;
}
if (b.label.toLowerCase().split(/\W+/).join(' ').indexOf(InputString.toLowerCase().split(/\W+/).join(' ')) < 0 && a.label.toLowerCase().split(/\W+/).join(' ').indexOf(InputString.toLowerCase().split(/\W+/).join(' ')) > -1) {
return -1;
}
// also with underscores ignored
if (a.label.toLowerCase().split(/\W+/).join(' ').replace('_', ' ').indexOf(InputString.toLowerCase().split(/\W+/).join(' ').replace('_', ' ')) < 0 && b.label.toLowerCase().split(/\W+/).join(' ').replace('_', ' ').indexOf(InputString.toLowerCase().split(/\W+/).join(' ').replace('_', ' ')) > -1) {
return 1;
}
if (b.label.toLowerCase().split(/\W+/).join(' ').replace('_', ' ').indexOf(InputString.toLowerCase().split(/\W+/).join(' ').replace('_', ' ')) < 0 && a.label.toLowerCase().split(/\W+/).join(' ').replace('_', ' ').indexOf(InputString.toLowerCase().split(/\W+/).join(' ').replace('_', ' ')) > -1) {
return -1;
}
// find all matching spaced words
if (InputString.toLowerCase().indexOf(' ') > -1) {
var lcInputStingFac = InputString.toLowerCase().split(' ');
var compare = (a1, a2) => a1.filter(v => a2.includes(v)).length;
var cA = compare(lcInputStingFac, a.label.toLowerCase().split(' '));
var cB = compare(lcInputStingFac, b.label.toLowerCase().split(' '));
if (cA > 0 || cB > 0) {
if (cA > cB) {
return -1;
}
if (cA < cB) {
return 1;
}
}
}
// find all tokenised word matches
if (InputString.split(/\W+/).length > 1) {
var lcInputStingFac = InputString.toLowerCase().split(/\W+/);
var compare = (a1, a2) => a1.filter(v => a2.includes(v)).length;
var cA = compare(lcInputStingFac, a.label.toLowerCase().split(/\W+/));
var cB = compare(lcInputStingFac, b.label.toLowerCase().split(/\W+/));
if (cA > 0 || cB > 0) {
if (cA > cB) {
return -1;
}
if (cA < cB) {
return 1;
}
}
}
// prioritise matches in the primary label
if (InputString.split(/\W+/).length > 1) {
var lcInputStingFac = InputString.toLowerCase().split(/\W+/);
var compare = (a1, a2) => a1.filter(v => a2.includes(v)).length;
var aLabel = a.label.split(' (');
var aEnd = aLabel.pop(aLabel.length);
aLabel = aLabel.join(' (');
var bLabel = b.label.split(' (');
var bEnd = bLabel.pop(bLabel.length);
bLabel = bLabel.join(' (');
var cA = compare(lcInputStingFac, aLabel.toLowerCase().split(/\W+/));
var cB = compare(lcInputStingFac, bLabel.toLowerCase().split(/\W+/));
if (cA > 0 || cB > 0) {
if (cA > cB) {
return -1;
}
if (cA < cB) {
return 1;
}
}
}
// if not found in one then advance the other
if (a.label.toLowerCase().indexOf(InputString.toLowerCase()) < 0 && b.label.toLowerCase().indexOf(InputString.toLowerCase()) > -1) {
return 1;
}
if (b.label.toLowerCase().indexOf(InputString.toLowerCase()) < 0 && a.label.toLowerCase().indexOf(InputString.toLowerCase()) > -1) {
return -1;
}
// if the match is closer to start than the other move up
if (a.label.toLowerCase().indexOf(InputString.toLowerCase()) > -1 && a.label.toLowerCase().indexOf(InputString.toLowerCase()) < b.label.toLowerCase().indexOf(InputString.toLowerCase())) {
return -1;
}
if (b.label.toLowerCase().indexOf(InputString.toLowerCase()) > -1 && b.label.toLowerCase().indexOf(InputString.toLowerCase()) < a.label.toLowerCase().indexOf(InputString.toLowerCase())) {
return 1;
}
// if the match in the id is closer to start then move up
if (a.id.toLowerCase().indexOf(InputString.toLowerCase()) > -1 && a.id.toLowerCase().indexOf(InputString.toLowerCase()) < b.id.toLowerCase().indexOf(InputString.toLowerCase())) {
return -1;
}
if (b.id.toLowerCase().indexOf(InputString.toLowerCase()) > -1 && b.id.toLowerCase().indexOf(InputString.toLowerCase()) < a.id.toLowerCase().indexOf(InputString.toLowerCase())) {
return 1;
}
// move the shorter synonyms to the top
if (a.label < b.label) {
return -1;
} else if (a.label > b.label) {
return 1;
} else {
return 0;
} // if nothing found then do nothing.
},
"clickHandler": function (id) {
window.addVfbId(id);
}
};
module.exports = {
searchStyle,
searchConfiguration,
datasourceConfiguration,
};