Skip to content

Commit aba0bad

Browse files
authored
Fix #2266 Multilang: use indexed fields in client queries (#2267)
1 parent 87b3016 commit aba0bad

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

geonode_mapstore_client/client/js/api/geonode/v2/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
paramsSerializer,
1313
getGeoNodeConfig,
1414
getGeoNodeLocalConfig,
15-
API_PRESET
15+
API_PRESET,
16+
getResourcesSearchIndex
1617
} from '@js/utils/APIUtils';
1718
import merge from 'lodash/merge';
1819
import mergeWith from 'lodash/mergeWith';
@@ -62,7 +63,7 @@ export const getResources = ({
6263
...getQueryParams({...params, f}, customFilters),
6364
...(q && {
6465
search: q,
65-
search_fields: ['title', 'abstract']
66+
search_index: getResourcesSearchIndex()
6667
}),
6768
...(sort && { sort: isArray(sort) ? sort : [ sort ]}),
6869
page,
@@ -102,7 +103,7 @@ export const getMaps = ({
102103
...params,
103104
...(q && {
104105
search: q,
105-
search_fields: ['title', 'abstract']
106+
search_index: getResourcesSearchIndex()
106107
}),
107108
...(sort && { sort: isArray(sort) ? sort : [ sort ]}),
108109
page,
@@ -138,7 +139,7 @@ export const getDatasets = ({
138139
'filter{metadata_only}': false,
139140
...(q && {
140141
search: q,
141-
search_fields: ['title', 'abstract']
142+
search_index: getResourcesSearchIndex()
142143
}),
143144
...(sort && { sort: isArray(sort) ? sort : [ sort ]}),
144145
page,
@@ -171,7 +172,7 @@ export const getDocumentsByDocType = (docType = 'image', {
171172
...params,
172173
...(q && {
173174
search: q,
174-
search_fields: ['title', 'abstract']
175+
search_index: getResourcesSearchIndex()
175176
}),
176177
...(sort && { sort: isArray(sort) ? sort : [ sort ]}),
177178
'filter{subtype}': [docType],
@@ -335,7 +336,7 @@ export const getGeoApps = ({
335336
...params,
336337
...(q && {
337338
search: q,
338-
search_fields: ['title', 'abstract']
339+
search_index: getResourcesSearchIndex()
339340
}),
340341
...(sort && { sort: isArray(sort) ? sort : [ sort ]}),
341342
page,

geonode_mapstore_client/client/js/utils/APIUtils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ export const paramsSerializer = () => {
132132
};
133133
};
134134

135+
export const getResourcesSearchIndex = () => {
136+
return getGeoNodeLocalConfig('geoNodeSettings.resourcesSearchIndex');
137+
};
138+
135139
export const API_PRESET = {
136140
CATALOGS: 'catalog_list',
137141
DATASETS: 'dataset_list',

geonode_mapstore_client/context_processors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ def resource_urls(request):
6868
"SUPPORTED_DATASET_FILE_TYPES": get_supported_datasets_file_types(),
6969
"RESOURCE_PUBLISHING": getattr(settings, "RESOURCE_PUBLISHING", False),
7070
"ADMIN_MODERATE_UPLOADS": getattr(settings, "ADMIN_MODERATE_UPLOADS", False),
71+
"RESOURCES_SEARCH_INDEX": getattr(settings, "RESOURCES_SEARCH_INDEX", "title_abstract"),
7172
}
7273
return defaults

geonode_mapstore_client/templates/geonode-mapstore-client/_geonode_config.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
let catalogPagePath = geoNodeSettings.CATALOG_PAGE_PATH;
7373
let isPublishedOptionEnabled = geoNodeSettings.RESOURCE_PUBLISHING || false;
7474
let isApprovedOptionEnabled = geoNodeSettings.ADMIN_MODERATE_UPLOADS || false;
75+
let resourcesSearchIndex = geoNodeSettings.RESOURCES_SEARCH_INDEX || 'title_abstract';
7576
let customFilters = geoNodeSettings.CUSTOM_FILTERS || {
7677
"my-resources": {
7778
"filter{owner.pk}": "{state('user') && state('user').pk}"
@@ -214,7 +215,8 @@
214215
catalogHomeRedirectsTo: catalogHomeRedirectsTo,
215216
catalogPagePath: catalogPagePath,
216217
isPublishedOptionEnabled: isPublishedOptionEnabled,
217-
isApprovedOptionEnabled: isApprovedOptionEnabled
218+
isApprovedOptionEnabled: isApprovedOptionEnabled,
219+
resourcesSearchIndex: resourcesSearchIndex
218220
}
219221
},
220222
};

geonode_mapstore_client/templates/geonode-mapstore-client/snippets/search_bar.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@
158158
const url = '/api/v2/resources' +
159159
'?page=' + options.page +
160160
'&search=' + options.value +
161-
'&search_fields=title' +
162-
'&search_fields=abstract' +
161+
'&search_index=' + window.__GEONODE_CONFIG__?.localConfig?.geoNodeSettings?.resourcesSearchIndex +
163162
'&filter{metadata_only}=false';
164163
{% endblock %}
165164
request = $.ajax({

0 commit comments

Comments
 (0)