geonode
geonode copied to clipboard
Elasticsearch haystack fails search
Expected Behavior
Searching for "members" should find the default group "Registered Members"
Actual Behavior
Nothing is found, the UI breaks

Steps to Reproduce the Problem
- create a geonode-project from the branch 3.2
- add elasticsearch service to the docker-compose.yml
elasticsearch:
image: elasticsearch:2.4.1
restart: unless-stopped
container_name: elasticsearch4${COMPOSE_PROJECT_NAME}
stdin_open: true
- enable search with haystack inside
.env
HAYSTACK_SEARCH=True
HAYSTACK_ENGINE_URL=http://elasticsearch:9200/
- start the docker
docker-compose up -d --build - search for "members"
Specifications
- GeoNode version: 3.2
- Installation method: geonode-project
- Platform: Linux
- Additional details:
The search uses a REST API http://localhost/api/base/search/?abstract__icontains=members&f_method=or&limit=5&offset=0&purpose__icontains=members&q=members which answers with a 404 error with the following json body
{
"error_message": "Sorry, no results on that page.",
"traceback": "Traceback (most recent call last):\n\n File \"/usr/src/geonode/geonode/api/resourcebase_api.py\", line 493, in get_search\n page = paginator.page(\n\n File \"/usr/local/lib/python3.8/site-packages/django/core/paginator.py\", line 70, in page\n number = self.validate_number(number)\n\n File \"/usr/local/lib/python3.8/site-packages/django/core/paginator.py\", line 47, in validate_number\n raise EmptyPage(_('That page number is less than 1'))\n\ndjango.core.paginator.EmptyPage: Quel numero di pagina è minore di 1\n\n\nDuring handling of the above exception, another exception occurred:\n\n\nTraceback (most recent call last):\n\n File \"/usr/local/lib/python3.8/site-packages/tastypie/resources.py\", line 228, in wrapper\n response = callback(request, *args, **kwargs)\n\n File \"/usr/src/geonode/geonode/api/resourcebase_api.py\", line 497, in get_search\n raise Http404(\"Sorry, no results on that page.\")\n\ndjango.http.response.Http404: Sorry, no results on that page.\n"
}
Using the MITM Proxy I was able to inspect the request made by geonode to elasticsearch, it returns the following body which has the expected hit:
{
"took":118,
"timed_out":false,
"_shards": {"total":5,"successful":5,"failed":0},
"hits":{"total":1,"max_score":null,"hits":[{"_index":"haystack","_type":"modelresult","_id":"1","_score":null,"_source":{"id": 1, "django_ct": "groups.groupprofile", "django_id": "1", "text": "\nRegistered Members\n\n[]", "title": "Registered Members", "title_sortable": "registered members", "description": "", "type": "group", "type_exact": "group", "json": "{\"_type\": \"group\", \"title\": \"Registered Members\", \"description\": \"\", \"keywords\": [], \"thumb\": \"/static/static/img/contact.png\", \"detail\": null}"},"sort":[-9223372036854775808]}]},
"aggregations":{"owner":{"meta":{"_type":"terms"},"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"type_exact":{"meta":{"_type":"terms"},"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[{"key":"group","doc_count":1}]},"category_exact":{"meta":{"_type":"terms"},"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"keywords_exact":{"meta":{"_type":"terms"},"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"subtype_exact":{"meta":{"_type":"terms"},"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"regions_exact":{"meta":{"_type":"terms"},"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]}}}