django-elasticsearch-dsl
django-elasticsearch-dsl copied to clipboard
ModelFieldNotMappedError
django_elasticsearch_dsl.exceptions.ModelFieldNotMappedError: Cannot convert model field price to an Elasticsearch field!
Currently I'm getting this kind of error Elasticsearch version : 6.1.0
Here's my documents.py
from django_elasticsearch_dsl import DocType, Index from crudapp.models import Product product=Index('products') @product.doc_type class ProductDocument(DocType): class Meta: model = Product fields = ['description', 'price', 'quantity']
having same issue, any luck?
class ProductDocument(DocType):
# set here fields Price Model you wanna use
price = NestedField(properties={
'value': fields.FloatField(),
'id': fields.IndegerField()
})
class Meta:
model = Product
related_model = [PriceModel]
fields = ['description', 'quantity']
You can also provide your own prepare__price(self, obj)
method.