geonetwork / geonetwork/core-geonetwork
"Query returned an error. Check the console for details." with provided Docker Compose file
- Dominant language
- Java
- Stars
- 521
- Forks
- 514
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 19
Description
The Overview on [hub.docker.com/_/geonetwork/](https://hub.docker.com/_/geonetwork/) currently provides the following example Compose file:
```yaml
# GeoNetwork
#
# Access via "http://localhost:8080/geonetwork"
#
# Default user: admin
# Default password: admin
volumes:
geonetwork:
esdata:
pgdata:
pglog:
services:
geonetwork:
image: geonetwork:4.4
healthcheck:
test: curl http://localhost:8080/
interval: 5s
timeout: 5s
retries: 30
restart: always
volumes:
- geonetwork:/catalogue-data
depends_on:
database:
condition: service_healthy
ports:
- 8080:8080
environment:
WEBAPP_CONTEXT_PATH: /geonetwork
DATA_DIR: /catalogue-data
TZ: Europe/Amsterdam
JAVA_OPTS: >-
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true
-Xms512M -Xss512M -Xmx2G -XX:+UseConcMarkSweepGC
-Djetty.httpConfig.requestHeaderSize=32768
-Dorg.eclipse.jetty.server.Request.maxFormContentSize=500000
-Dorg.eclipse.jetty.server.Request.maxFormKeys=4000
# For remote debug
# -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
GN_CONFIG_PROPERTIES: >-
-Dgeonetwork.dir=/catalogue-data
-Dgeonetwork.formatter.dir=/catalogue-data/data/formatter
-Dgeonetwork.schema.dir=/opt/geonetwork/WEB-INF/data/config/schema_plugins
-Dgeonetwork.indexConfig.dir=/opt/geonetwork/WEB-INF/data/config/index
-Dgeonetwork.schemapublication.dir=/opt/geonetwork/WEB-INF/data/resources/schemapublication
-Dgeonetwork.htmlcache.dir=/opt/geonetwork/WEB-INF/data/resources/htmlcache
-Des.host=elasticsearch
-Des.protocol=http
-Des.port=9200
-Des.url=http://elasticsearch:9200
-Des.username=
-Des.password=
-Dgeonetwork.ESFeaturesProxy.targetUri=http://elasticsearch:9200/gn-features/{_}
-Dgeonetwork.HttpDashboardProxy.targetUri=http://kibana:5601
GEONETWORK_DB_TYPE: postgres-postgis
GEONETWORK_DB_HOST: database
GEONETWORK_DB_PORT: 5432
GEONETWORK_DB_NAME: geonetwork
GEONETWORK_DB_USERNAME: geonetwork
GEONETWORK_DB_PASSWORD: geonetwork
database:
image: postgis/postgis:16-3.4
environment:
POSTGRES_USER: geonetwork
POSTGRES_PASSWORD: geonetwork
POSTGRES_DB: geonetwork
command: [postgres, -c, log_statement=all, -c, logging_collector=true, -c, log_file_mode=0644, -c, log_directory=/var/log/postgresql, -c, log_filename=postgresql.log]
healthcheck:
test: [CMD-SHELL, pg_isready -U postgres]
interval: 5s
timeout: 5s
retries: 5
volumes:
- pgdata:/var/lib/postgresql/data
- pglog:/var/log/postgresql
elasticsearch:
image: elasticsearch:7.17.15
ports:
- 9200:9200
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
healthcheck:
test: curl -s http://localhost:9200 >/dev/null || exit 1
interval: 10s
timeout: 2s
retries: 10
start_period: 2m
environment:
ES_JAVA_OPTS: -Xms1G -Xmx1G
discovery.type: single-node
volumes:
- esdata:/usr/share/elasticsearch/data
kibana:
image: kibana:7.17.15
environment:
SERVER_NAME: kibana
ELASTICSEARCH_URL: http://elasticsearch:9200/
SERVER_BASEPATH: /geonetwork/dashboards
SERVER_REWRITEBASEPATH: 'false'
KIBANA_INDEX: .dashboards
XPACK_MONITORING_UI_CONTAINER_ELASTICSEARCH_ENABLED: 'true'
depends_on:
elasticsearch:
condition: service_healthy
```
Unfortunately, this configuration does not work out-of-the-box as one would expect: I get "Query returned an error. Check the console for details." errors in the browser if I run GeoNetwork this way. (To reproduce, place the above in a file named `docker-compose.yml` and run `docker-compose up` from the directory containing it.)
Note that, due to the nature of my setup, I had to change `image: geonetwork:4.4` to `image: geonetwork:4.4.9`, but that shouldn't matter. And I already noticed that the line `-Dkb.url=http://kibana:5601` appears to be missing from `GN_CONFIG_PROPERTIES`, but adding it didn't help.
The error message appears to be referring to the browser console, not the container logs. On a fresh instance, I see the a warning like this in the JS console: An error occurred while searching. Bad request. [object]\n[object] Right-click on the second object → (Firefox:) Store as Global Variable (creates `temp0`) → `temp0.message` has the error message, but the HTML `"` escapes make it near-unreadable. `var div = document.createElement('DIV'); div.innerHTML = temp0.message; console.log(div.innerText);` This prints a request that includes `"sort":[{"createDate":"desc"},"_score"]` and an error that includes `"reason":"No mapping found for [createDate] in order to sort on"`.
Full request (prettified)
```json
{
"from": 0, "size": 12,
"sort": [{"createDate": "desc"}, "_score"],
"query": {
"function_score": {
"boost": "5",
"functions": [
{"filter": {"match": {"resourceType": "series"}}, "weight": 1.5},
{"filter": {"exists": {"field": "parentUuid"}}, "weight": 0.3},
{"filter": {"match": {"cl_status.key": "obsolete"}}, "weight": 0.2},
{"filter": {"match": {"cl_status.key": "superseded"}}, "weight": 0.3},
{"gauss": {"changeDate": {"scale": "365d", "offset": "90d", "decay": 0.5}}}
],
"score_mode": "multiply",
"query": {
"bool": {
"must": [{"terms": {"isTemplate": ["n"]}}],
"filter": {"query_string": {"query": "(op0:(1) ) AND (draft:n OR draft:e)"}}
}
}
}
},
"aggregations": {},
"_source": {
"includes": ["id", "uuid", "creat*", "cl_topic*", "inspire*", "resource*", "image*", "tag*", "op*", "documentStandard", "groupOwner", "owner", "id"]
},
"script_fields": {
"overview": {
"script": {
"source": "return params['_source'].overview == null ? [] : params['_source'].overview.stream().findFirst().orElse([]);"
}
}
}
}
```
Full error
```json
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "No mapping found for [createDate] in order to sort on",
"index_uuid": "UPrc59FDQDSi81tH1B8qLA",
"index": "gn-records"
}
],
"type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true,
"failed_shards": [
{
"shard": 0, "index": "gn-records", "node": "5JMlZDl0S0Oxeg7DvitXMQ",
"reason": {
"type": "query_shard_exception",
"reason": "No mapping found for [createDate] in order to sort on",
"index_uuid": "UPrc59FDQDSi81tH1B8qLA",
"index": "gn-records"
}
}
]
},
"status": 400
}
```
If I [load templates and samples](https://docs.geonetwork-opensource.org/4.4/install-guide/loading-samples/), however, the error and the failing request change. The error also now only shows up on the Search page, no longer on Home.
Request
```json
{
"from": 0, "size": 30, "sort": ["_score"],
"query": {
"function_score": {
"boost": "5",
"functions": [
{"filter": {"match": {"resourceType": "series"}}, "weight": 1.5},
{"filter": {"exists": {"field": "parentUuid"}}, "weight": 0.3},
{"filter": {"match": {"cl_status.key": "obsolete"}}, "weight": 0.2},
{"filter": {"match": {"cl_status.key": "superseded"}}, "weight": 0.3},
{"gauss": {"changeDate": {"scale": "365d", "offset": "90d", "decay": 0.5}}}
],
"score_mode": "multiply",
"query": {
"bool": {
"must": [{"terms": {"isTemplate": ["n"]}}],
"filter": {"query_string": {"query": "*:* AND (draft:n OR draft:e)"}}
}
}
}
},
"aggregations": {
"resourceType": {
"terms": {"field": "resourceType"},
"meta": {
"decorator": {"type": "icon", "prefix": "fa fa-fw gn-icon-"},
"field": "resourceType"
}
},
"cl_spatialRepresentationType.key": {
"terms": {"field": "cl_spatialRepresentationType.key", "size": 10},
"meta": {"field": "cl_spatialRepresentationType.key"}
},
"format": {
"terms": {"field": "format"},
"meta": {"collapsed": true, "field": "format"}
},
"availableInServices": {
"filters": {
"filters": {
"availableInViewService": {"query_string": {"query": "+linkProtocol:/OGC:WMS.*/"}},
"availableInDownloadService": {"query_string": {"query": "+linkProtocol:/OGC:WFS.*/"}}
}
},
"aggs": {
"keep_nonzero": {
"bucket_selector": {
"buckets_path": {"count": "_count"},
"script": "params.count > 0"
}
}
},
"meta": {
"decorator": {
"type": "icon", "prefix": "fa fa-fw ",
"map": {"availableInViewService": "fa-globe", "availableInDownloadService": "fa-download"}
}
}
},
"th_gemet_tree.key": {
"terms": {
"field": "th_gemet_tree.key", "size": 100,
"order": {"_key": "asc"},
"include": "[^^]+^?[^^]+"
},
"meta": {"field": "th_gemet_tree.key"}
},
"th_httpinspireeceuropaeumetadatacodelistPriorityDataset-PriorityDataset_tree.default": {
"terms": {
"field": "th_httpinspireeceuropaeumetadatacodelistPriorityDataset-PriorityDataset_tree.default",
"size": 100, "order": {"_key": "asc"}
},
"meta": {"field": "th_httpinspireeceuropaeumetadatacodelistPriorityDataset-PriorityDataset_tree.default"}
},
"th_httpinspireeceuropaeutheme-theme_tree.key": {
"terms": {"field": "th_httpinspireeceuropaeutheme-theme_tree.key", "size": 34},
"meta": {
"decorator": {"type": "icon", "prefix": "fa fa-fw gn-icon iti-", "expression": "http://inspire.ec.europa.eu/theme/(.*)"},
"field": "th_httpinspireeceuropaeutheme-theme_tree.key"
}
},
"tag": {
"terms": {"field": "tag.langeng", "include": ".*", "size": 10},
"meta": {"caseInsensitiveInclude": true, "field": "tag.langeng"}
},
"th_regions_tree.default": {
"terms": {
"field": "th_regions_tree.default", "size": 100,
"order": {"_key": "asc"}
},
"meta": {"field": "th_regions_tree.default"}
},
"resolutionScaleDenominator": {
"histogram": {"field": "resolutionScaleDenominator", "interval": 10000, "keyed": true, "min_doc_count": 1},
"meta": {"collapsed": true}
},
"creationYearForResource": {
"histogram": {"field": "creationYearForResource", "interval": 5, "keyed": true, "min_doc_count": 1},
"meta": {"collapsed": true}
},
"OrgForResource": {
"terms": {"field": "OrgForResourceObject.langeng", "include": ".*", "size": 20},
"meta": {"caseInsensitiveInclude": true, "field": "OrgForResourceObject.langeng"}
},
"cl_maintenanceAndUpdateFrequency.key": {
"terms": {"field": "cl_maintenanceAndUpdateFrequency.key", "size": 10},
"meta": {"collapsed": true, "field": "cl_maintenanceAndUpdateFrequency.key"}
}
},
"_source": {
"includes": ["uuid", "id", "groupOwner", "logo", "cat", "inspireThemeUri", "inspireTheme_syn", "cl_topic", "resourceType", "resourceTitle*", "resourceAbstract*", "draft", "draftId", "owner", "link", "status*", "rating", "geom", "contact*", "Org*", "isTemplate", "valid", "isHarvested", "dateStamp", "documentStandard", "standardNameObject.default", "cl_status*", "mdStatus*", "op*", "documentStandard", "groupOwner", "owner", "id"]
},
"script_fields": {"overview": {"script": {"source": "return params['_source'].overview == null ? [] : params['_source'].overview.stream().findFirst().orElse([]);"}}},
"track_total_hits": true
}
```
Error
```json
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [cl_spatialRepresentationType.key] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
],
"type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true,
"failed_shards": [
{
"shard": 0, "index": "gn-records", "node": "5JMlZDl0S0Oxeg7DvitXMQ",
"reason": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [cl_spatialRepresentationType.key] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [cl_spatialRepresentationType.key] in order to load field data by uninverting the inverted index. Note that this can use significant memory.",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [cl_spatialRepresentationType.key] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
},
"status": 400
}
```
And in addition to the above info in the console warning, there now is a console error Possibly unhandled rejection: [JSON], where the JSON object has (among others) an attribute `data`, which in turn has an attribute `message`, which is an error message string that looks like `temp0.message` above and which contains the following information:
Request
```json
{
"size": 0, "track_total_hits": true,
"query": {
"bool": {
"must": {"query_string": {"query": "+isTemplate:n"}},
"filter": {"query_string": {"query": "*:* AND (draft:n OR draft:e)"}}
}
},
"aggs": {
"th_httpinspireeceuropaeutheme-theme_tree.key": {
"terms": {"field": "th_httpinspireeceuropaeutheme-theme_tree.key", "size": 34},
"meta": {
"decorator": {"type": "icon", "prefix": "fa fa-2x pull-left gn-icon iti-", "expression": "http://inspire.ec.europa.eu/theme/(.*)"},
"orderByTranslation": true
}
},
"cl_topic.key": {
"terms": {"field": "cl_topic.key", "size": 20},
"meta": {
"decorator": {"type": "icon", "prefix": "fa fa-2x pull-left gn-icon-"},
"orderByTranslation": true
}
},
"resourceType": {
"terms": {"field": "resourceType", "size": 10},
"meta": {
"decorator": {"type": "icon", "prefix": "fa fa-2x pull-left gn-icon-"}
}
}
}
}
```
Error
```json
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [cl_topic.key] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
],
"type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true,
"failed_shards": [
{
"shard": 0, "index": "gn-records", "node": "5JMlZDl0S0Oxeg7DvitXMQ",
"reason": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [cl_topic.key] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [cl_topic.key] in order to load field data by uninverting the inverted index. Note that this can use significant memory.",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [cl_topic.key] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
},
"status": 400
}
```
I hope all of this is just due to a simple oversight in the provided Compose file that's easily corrected by someone who has a better understanding of GeoNetwork than me.
I just noticed that geonetwork/docker-geonetwork#144 appears to be a duplicate of this? Sadly, that issue has not received any attention. Maybe this more detailed writeup will help?
Contributor guide
Research direction
Start with the provided docker-compose.yml and reproduce the issue with docker-compose up, then inspect the browser console request and Elasticsearch error showing that createDate has no mapping. Compare the fresh-instance behavior with the behavior after loading templates and samples. Done means the Compose setup no longer produces the reported query errors on Home and Search.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, elasticsearch, java, postgresql
- Domain
- backend, databases, devops, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100