AALAP JETHWA
AALAP JETHWA

Reputation: 160

django-elasticsearch-dsl-drf: TypeError: search() got an unexpected keyword argument 'doc_type'

I am creating an django API with Elastic search, using below libraries:

When api is called, django-elasticsearch-dsl-drf library throws error:

search() got an unexpected keyword argument 'doc_type'

Here is my code:

serializers.py

class TestSerializer(DocumentSerializer):
    class Meta(object):
        document = TestDocument
        fields = ("id", "name")

api.py

class TestDocumentViewSet(DocumentViewSet):
 document = TestDocument
 serializer_class = TestSerializer
 lookup_field = 'id'
 filter_backends = [
    CompoundSearchFilterBackend,
 ]
 multi_match_search_fields  = ('id', 'name')
 filter_fields = {
     'id': 'id',
     'name': 'name',
 }
 ordering_fields = {
     'id': 'id',
     'name': 'name',
 }
 ordering = ('id', 'name')

Can someone please help me out with this?

Upvotes: 0

Views: 1275

Answers (2)

Krishna Kumar
Krishna Kumar

Reputation: 449

Yesterday I faced the same problem You need to check the elasticsearch version or You can directly download the version by this command - sudo pip install elasticsearch==version(e.g 6.3.1) You can check elastic version by this command - pip freeze

Upvotes: 2

wasim
wasim

Reputation: 11

check elasticsearch version. hopefully using compatible versions should solve this problem.

Upvotes: 1

Related Questions