Skip to content
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

How to remove the _class field when automatically creating index and how to specify what fields we want return in query? #1883

Closed
fengnex opened this issue Jul 27, 2021 · 5 comments

Comments

@fengnex
Copy link

fengnex commented Jul 27, 2021

There are two questions:

  1. A field named _class will be inserted automatically when spring-data-elasticsearch creates an index, even though it is not desired. I wonder how to avoid that.
  2. *Repository always return ALL fields from elasticsearch after querying, and how to specify the fields we want to return? Not ALL.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 27, 2021
@sothawo
Copy link
Collaborator

sothawo commented Jul 27, 2021

  1. A field named _class will be inserted automatically when spring-data-elasticsearch creates an index, even though it is not desired. I wonder how to avoid that.

Implemented with #1788, this is contained since release 4.3.0-M1, check the documentation for details (last part of the linked chapter).

  1. Repository always return ALL fields from elasticsearch after querying, and how to specify the fields we want to return? Not ALL.

Currently not possible with repository methods, only when you use an ElasticsearchOperations implementation when sednding a query. The Query has setFields() or addSourceFilter() for this purpose.

@sothawo sothawo added the status: waiting-for-feedback We need additional information before we can continue label Jul 27, 2021
@fengnex
Copy link
Author

fengnex commented Jul 28, 2021

@sothawo Thank you and I found that _class seems necessary and it is recommended not to disable it.
BTW, the following statement in the document specified in the above post actually cannot work because java compiler will complain "Cannot resolve method 'writeTypeHint'":
@document(indexName = "index", writeTypeHint = WriteTypeHint.FALSE)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 28, 2021
@sothawo
Copy link
Collaborator

sothawo commented Jul 31, 2021

Do you use the current milestone version for 4.3 (4.3.0-M1)? If you get this compiler version you are using one of the released versions.

@sothawo sothawo added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Jul 31, 2021
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Aug 7, 2021
@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Aug 14, 2021
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

No branches or pull requests

3 participants