Skip to content

Replace type:'string' with type'text' for elasticsearch 5 compaitbility. #1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

msapiro
Copy link

@msapiro msapiro commented May 25, 2019

The string type is removed in elasticsearch 5. There is an automatic conversion to text but this doesn't support parameters like boost.

Attempts to PUT _mapping/modelresult with items like 'subject': {'type': 'string', 'analyzer': 'snowball', 'boost': 1.25}, result in a 400 error with the exception {'error': {'root_cause': [{'type': 'illegal_argument_exception', 'reason': 'The [string] type is removed in 5.0 and automatic upgrade failed because parameters [boost] are not supported for automatic upgrades. You should now use either a [text] or [keyword] field instead for field [subject]'}], 'type': 'illegal_argument_exception', 'reason': 'The [string] type is removed in 5.0 and automatic upgrade failed because parameters [boost] are not supported for automatic upgrades. You should now use either a [text] or [keyword] field instead for field [subject]'}, 'status': 400}

This PR modifies backends/elasticsearch5_backend.py to change string to text in the imported backends/elasticsearch_backend.py settings DEFAULT_FIELD_MAPPING and FIELD_MAPPINGS

@msapiro
Copy link
Author

msapiro commented May 25, 2019

There are a number of failed tests using elasticsearch 5. I suspect even without the changes in this PR, several elasticsearch 5 tests will fail although they may be different failures.

Some of the failures may because things that used to return type: "string" now return type: "text", but others may be because a type should be keyword rather than text. Clearly a proper fix is more complex than this PR, and I don't yet know how to fix it. The changes in the PR work for me, but my model only has indexes.CharField, indexes.DateTimeField and indexes.MultiValueField so it is fairly simple.

@cclauss
Copy link
Contributor

cclauss commented Apr 17, 2023

Are these changes still needed? If so, please rebase on the current master.

@msapiro
Copy link
Author

msapiro commented Apr 18, 2023

Are these changes still needed? If so, please rebase on the current master.

They are still needed. I note this issue was fixed in django-haystack/haystack/backends/elasticsearch7_backend.py by redefining DEFAULT_FIELD_MAPPING and FIELD_MAPPINGS. I think this is a better approach so I have changed this PR to apply that fix to django-haystack/haystack/backends/elasticsearch5_backend.py as well.

@jochengcd
Copy link
Contributor

for consistency with the change #1965 for ES7 these c/should be class variables and used in build_schema with self.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy