Skip to content

Add the type hint _class attribute to the index mapping #1711

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

Closed
sothawo opened this issue Feb 28, 2021 · 0 comments · Fixed by #1717
Closed

Add the type hint _class attribute to the index mapping #1711

sothawo opened this issue Feb 28, 2021 · 0 comments · Fixed by #1717
Assignees
Labels
type: enhancement A general enhancement

Comments

@sothawo
Copy link
Collaborator

sothawo commented Feb 28, 2021

Spring Data Elasticsearch use type hints to store information in the index about the persisted entity's class. This is the fully qualified name of the entity's class, stored in a field named _class.

This field is not defined in the index mappings, so it is automatically mapped by Elasticsearch when the first entity is persisted to the following definition:

"_class": {
  "type": "text",
  "fields": {
    "keyword": {
      "type": "keyword",
      "ignore_above": 256
    }
  }
}

This field is never used for search, so it does not need to be analyzed or indexed at all. Having it mapped in this way is a waste of storage place and indexing time.

The type hint field should be defined in the mapping as

"_class": {
  "type": "keyword",
  "index": false,
  "doc_values": false
}
@sothawo sothawo added the type: enhancement A general enhancement label Feb 28, 2021
@sothawo sothawo self-assigned this Feb 28, 2021
sothawo added a commit that referenced this issue Mar 4, 2021
@sothawo sothawo added this to the 4.2 M5 (2021.0.0) milestone Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant