Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

elastic search model init() raise key error

According to the documentation I've created class with some of my model fields to perform search later. Also I've created conection with default params. But I can't call init() for UserIndex

from elasticsearch_dsl import DocType, Text, Boolean, Date, Keyword
from elasticsearch_dsl.connections import connections

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

class UserIndex(DocType):
    pk = Text()
    phone_number = Text()
    nickname = Text()
    name = Text()
    birth_date = Date()
    class Meta:
        index = 'user'

After UserIndex.init() command I'm getting an error:

  File ".../lib/python3.6/site-packages/elasticsearch_dsl/document.py", line 138, in init
    i.save(using=using)
  File ".../lib/python3.6/site-packages/elasticsearch_dsl/index.py", line 289, in save
    current_settings = self.get_settings(using=using)[self._name]['settings']['index']
KeyError: '*'
like image 757
Ernst Avatar asked Apr 27 '26 09:04

Ernst


1 Answers

What version of elasticsearch-dsl are you using? It looks like the latest version (6.3.0) is having issues (This posted issue seems similar).

Rolling back to 6.2.1 resolved this error for me.

like image 86
TooPricey Avatar answered Apr 30 '26 03:04

TooPricey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!