django-elasticsearch-dsl icon indicating copy to clipboard operation
django-elasticsearch-dsl copied to clipboard

./manage.py search_index --rebuild does not work

Open pausanchezv opened this issue 4 years ago • 6 comments

./manage.py search_index --rebuild returns RequestError(400, 'mapper_parsing_exception', 'Root mapping definition has unsupported parameters. It doesn't matter what I do, it keeps failing. I'm, using Django 3 with the latest version of elasticsearch dsl.

pausanchezv avatar Sep 22 '20 13:09 pausanchezv

Hello, you should give following details:

  • schema of your Documents / models (anything particular ?)
  • version of your Elasticsearch instance

alexgarel avatar Sep 22 '20 14:09 alexgarel

Okay, thanks for answering, this is what I have:

When I write the instruction ./manage.py search_index --rebuild it asks me the following question: Are you sure you want to delete the 'ratings' indexes? [y/N].

Then I type yes. And it throws this error:

raise HTTP_EXCEPTIONS.get(status_code, TransportError)( elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'Root mapping definition has unsupported parameters: [value : {type=double}]')

Value is the attribute I'm trying to index. It belongs to a django model. For now I wanna keep it as simple as possible by indexing only one attribute. So my documents.py looks like this:

@registry.register_document class RatingDocument(Document): class Index:

    # Name of the Elasticsearch index
    name = 'ratings'

    # See Elasticsearch Indices API reference for available settings
    settings = {'number_of_shards': 1,
                'number_of_replicas': 0}

class Django:
    model = Rating 

    # The fields of the model you want to be indexed in Elasticsearch
    fields = [
        'value',
    ]

And this is what my model looks like:

class Rating(models.Model): user_from = models.ForeignKey(to='accounts.User', on_delete=models.CASCADE, related_name='ratings_sent') user_to = models.ForeignKey(to='accounts.User', on_delete=models.CASCADE, related_name='ratings_received') value = models.FloatField(default=0) date = models.DateTimeField(default=datetime.datetime.now)

def __str__(self):
    return f"{self.user_from.pk}::{self.user_to.pk}::{self.value}"

Those are the versions installed in my system alongside Django 3.1

django-elasticsearch-dsl==7.1.4 elasticsearch==7.6.0 elasticsearch-dsl==7.1.0

The only thing I did was install django-elasticsearch-dsl amd the rest was automatically added to the virtual env. I'm NOT using docker, only a python virtual environment.

Do you need any more details. Let me know and I'll provide you with anything you need.

Pau.

pausanchezv avatar Sep 22 '20 14:09 pausanchezv

Hello, you should give following details:

  • schema of your Documents / models (anything particular ?)
  • version of your Elasticsearch instance

Okay, thanks for answering, this is what I have:

When I write the instruction ./manage.py search_index --rebuild it asks me the following question: Are you sure you want to delete the 'ratings' indexes? [y/N].

Then I type yes. And it throws this error:

raise HTTP_EXCEPTIONS.get(status_code, TransportError)( elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'Root mapping definition has unsupported parameters: [value : {type=double}]')

Value is the attribute I'm trying to index. It belongs to a django model. For now I wanna keep it as simple as possible by indexing only one attribute. So my documents.py looks like this:

@registry.register_document class RatingDocument(Document): class Index:

# Name of the Elasticsearch index
name = 'ratings'

# See Elasticsearch Indices API reference for available settings
settings = {'number_of_shards': 1,
            'number_of_replicas': 0}

class Django: model = Rating

# The fields of the model you want to be indexed in Elasticsearch
fields = [
    'value',
]

And this is what my model looks like:

class Rating(models.Model): user_from = models.ForeignKey(to='accounts.User', on_delete=models.CASCADE, related_name='ratings_sent') user_to = models.ForeignKey(to='accounts.User', on_delete=models.CASCADE, related_name='ratings_received') value = models.FloatField(default=0) date = models.DateTimeField(default=datetime.datetime.now)

def str(self): return f"{self.user_from.pk}::{self.user_to.pk}::{self.value}" Those are the versions installed in my system alongside Django 3.1

django-elasticsearch-dsl==7.1.4 elasticsearch==7.6.0 elasticsearch-dsl==7.1.0

The only thing I did was install django-elasticsearch-dsl amd the rest was automatically added to the virtual env. I'm NOT using docker, only a python virtual environment.

Do you need any more details. Let me know and I'll provide you with anything you need.

Pau.

pausanchezv avatar Sep 30 '20 06:09 pausanchezv

Hello, you should give following details:

  • schema of your Documents / models (anything particular ?)
  • version of your Elasticsearch instance

Hello!, Do you need any more info?

Those are the versions installed in my system alongside Django 3.1

django-elasticsearch-dsl==7.1.4 elasticsearch==7.6.0 elasticsearch-dsl==7.1.0

pausanchezv avatar Oct 06 '20 06:10 pausanchezv

@pausanchezv Which Elasticsearch version?

safwanrahman avatar Oct 27 '20 02:10 safwanrahman

@pausanchezv

I am able to create it without any mapper issue on type doubel, please find the versions as below:

elasticsearch 7.10.0 elasticsearch-dsl 7.3.0 django-elasticsearch-dsl 7.1.4 Django 3.0

Elasticsearch url /ratings as below: {"ratings":{"aliases":{},"mappings":{"properties":{"value":{"type":"double"}}},"settings":{"index":{"creation_date":"1608215505992","number_of_shards":"1","number_of_replicas":"1","uuid":"u_YU0RcQSICqEi8gSAZVYA","version":{"created":"7090399"},"provided_name":"ratings"}}}}

Rebuild command without error as below:

~/Desktop/Projects/External_pr/EL2$ python manage.py search_index --rebuild Are you sure you want to delete the 'ratings' indexes? [y/N]: y Deleting index 'ratings' Creating index 'ratings' Indexing 0 'Rating' objects

Murugaraju avatar Dec 17 '20 14:12 Murugaraju