5👍
Ok I’ve figured out what the problem is:
In Elasticsearch 2.0, there are metadata changes, one of which is boost
that has been removed: https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_mapping_changes.html#migration-meta-fields
Tracing back through elasticsearch/transport.py
, the PUT request to http://127.0.0.1:9200/myindex/_mapping/modelresult includes “_boost”: {“name”: “boost”, “null_value”: 1.0} in the body.
So tracing the calls and represting them as CURL:
CREATE THE INDEX
curl -X PUT -d '{"settings": {"analysis": {"filter": {"haystack_edgengram": {"max_gram": 15, "type": "edgeNGram", "min_gram": 2}, "haystack_ngram": {"max_gram": 15, "type": "nGram", "min_gram": 3}}, "tokenizer": {"haystack_ngram_tokenizer": {"max_gram": 15, "type": "nGram", "min_gram": 3}, "haystack_edgengram_tokenizer": {"max_gram": 15, "type": "edgeNGram", "side": "front", "min_gram": 2}}, "analyzer": {"edgengram_analyzer": {"filter": ["haystack_edgengram", "lowercase"], "type": "custom", "tokenizer": "standard"}, "ngram_analyzer": {"filter": ["haystack_ngram", "lowercase"], "type": "custom", "tokenizer": "standard"}}}}}' http://127.0.0.1:9200/myindex
THE FAILING REQUEST
curl -X PUT -d '{"modelresult": {"_boost": {"name": "boost", "null_value": 1.0}, "properties": {"django_id": {"include_in_all": false, "index": "not_analyzed", "type": "string"}, "description": {"type": "string", "analyzer": "snowball"}, "created": {"type": "date"}, "text": {"type": "string", "analyzer": "snowball"}, "django_ct": {"include_in_all": false, "index": "not_analyzed", "type": "string"}, "location": {"type": "geo_point"}}}}' http://127.0.0.1:9200/myindex/_mapping/modelresult
Changing to this works
curl -X PUT -d '{"modelresult": {"properties": {"django_id": {"include_in_all": false, "index": "not_analyzed", "type": "string"}, "description": {"type": "string", "analyzer": "snowball"}, "created": {"type": "date"}, "text": {"type": "string", "analyzer": "snowball"}, "django_ct": {"include_in_all": false, "index": "not_analyzed", "type": "string"}, "location": {"type": "geo_point"}}}}' http://127.0.0.1:9200/myindex/_mapping/modelresult
So, the python fix
In haystack/backends/elasticsearch_backend.py, comment out the boost section from current_mapping on line 137-140
0👍
Maybe it does not work, because get_location
is not a field on MyModel
.
Maybe you can avoid creating location as a field by adding @property
decorator, like this:
from haystack.utils.geo import Point
@property
def get_location(self):
return Point(self.lng, self.lat)
EDIT: This does not look like it will solve a problem. You have it just like it is in documentation.
- [Django]-Django: Add number of results
- [Django]-NoReverseMatch error when creating new users through admin
- [Django]-Add custom button near Save button Django-admin
- [Django]-Django, dynamic apps support
- [Django]-Websocket connection not working in Django Channels ('WebSocket connection to 'ws://localhost:8000/ws/board/7/' failed:')