6

I am following https://github.com/sabricot/django-elasticsearch-dsl to index the data inside my django-model. I have defined my documents.py file as :->

from django_elasticsearch_dsl import Document , fields 
from django_elasticsearch_dsl.registries import registry
from abc.models import *
from elasticsearch_dsl import connections, field, analyzer


connections.create_connection(hosts=['localhost'], timeout=20)


@registry.register_document
class ParkingDocument(Document):
   class Index:
    # Name of the Elasticsearch index
    name = 'parking'
    # See Elasticsearch Indices API reference for available settings
    settings = {'number_of_shards': 1,
                'number_of_replicas': 0}

   class Django:
    model = ParkingLocation

    fields = [
        'created',
        'updated',
    ]

When i run the command python manage.py search_index --rebuild. I get error as mentioned in title. Any help would be appreciated.

Prayag Bhatia
  • 366
  • 3
  • 16

1 Answers1

3

Looks like you are using the old version of elasticsearch where types is mandatory, but in your query, you are not including it.

In the current version of ES, types are deprecated see. Please provide which version of elasticsearch and client you are using ?

and follow these link and below to see the compitable versions:

Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Types will be deprecated in APIs in Elasticsearch 7.0.0, and completely removed in 8.0.0.

Amit
  • 30,756
  • 6
  • 57
  • 88