Closed lanhui100 closed 9 months ago
Hello! The more_like_this
functionality comes from django-elasticsearch-dsl-drf. We have four libraries involved here:
To keep using Elasticsearch 8, you could create a more-like-this query without using django-elasticsearch-dsl-drf. elasticsearch-dsl-py supports it: https://elasticsearch-dsl.readthedocs.io/en/latest/search_dsl.html#more-like-this-query. Which means you could use django-elasticsearch-dsl
to automatically get a Document
for you and run this query. See https://django-elasticsearch-dsl.readthedocs.io/en/latest/quickstart.html for details.
In any case, closing as this is not an elasticsearch-py bug. Thank you!
thank you. I have located the bug in MoreLikeThisMixin of django-elasticsearch-dsl-drf. The library seems out of date.
django_restframework project more_like_this query bug:
Elasticsearch version (
bin/elasticsearch --version
): 8.11.0elasticsearch-py
version (elasticsearch.__versionstr__
): 8.11.0Please make sure the major version matches the Elasticsearch server you are running.
Description of the problem including expected versus actual behavior: post more_like_this query: Error Info: BadRequestError at /api/v1/cdd/search/resume/1/more_like_this/ BadRequestError(400, 'parsing_exception', 'failed to parse More Like This item. unknown field [_type]')
Local vars: body: {'query': {'more_like_this': {'fields': ('education_experience.school_name', 'education_experience.major', 'education_experience.degree', 'work_experience.company_name', 'work_experience.job_title', 'work_experience.description'), 'like': {'_id': '1', '_index': 'resume', '_type': 'properties'}}}}
[ It seems that ES 8 have already remove the _type params? but this version ES-py seems not sync.] Steps to reproduce: ![Uploading 1702960354357.png…]()