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

Reactive repository ignores entity class annotations [DATAES-655] #1231

Closed
spring-projects-issues opened this issue Sep 17, 2019 · 3 comments
Closed
Labels
in: core in: repository type: enhancement

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 17, 2019

Alexandre Gianquinto opened DATAES-655 and commented

When using ReactiveElasticSearchRepository, all annotations on the entity class are ignored.

For example :

 

@Repository
public interface TestClassRepository extends ReactiveElasticsearchRepository<TestClass, Long> {
}

with entity class :

@Document(indexName = "test")
public class TestClass {

    @CompletionField
    private Completion completion;

    @Id
    private Long id;

    public Completion getCompletion() {
        return completion;
    }

    public void setCompletion(Completion completion) {
        this.completion = completion;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
}

will result into generating those mappings into ES :

"test": {
        "mappings": {
            "properties": {
                "completion": {
                    "properties": {
                        "input": {
                            "type": "text",
                            "fields": {
                                "keyword": {
                                    "type": "keyword",
                                    "ignore_above": 256
                                }
                            }
                        }
                    }
                },
                "id": {
                    "type": "long"
                }
            }
        }
    }

...when the expected output (Realized with blocking ElasticSearchRepository) should be :

"test": {
        "mappings": {
            "properties": {
                "completion": {
                    "type": "completion",
                    "analyzer": "simple",
                    "preserve_separators": true,
                    "preserve_position_increments": true,
                    "max_input_length": 50
                },
                "id": {
                    "type": "long"
                }
            }
        }
    }

Tested by simply switching Reactive to Standard springData repository, the mappings do not match. The consequence is that most of the suggest, custom field configs, etc... won't work with Reactive repositories, on both index/mappings generation and querying/inserting operations


Affects: 3.2 RC3 (Moore)

Issue Links:

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 19, 2019

sothawo commented

The reactive repository does not auto-create the index with the mapping. As autocreation is often problematic we probably should not add it to the repository class, but we need to add the necessary methods to the ReactiveElasticsearchOperations class.

As a workaround you can additionally define a non-reactive interface for your @Document class without using it, this will on startup create the index and mapping and then the index can be used with the reactive repository. But be aware hat this does on index creation blocking calls to the cluster

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 19, 2019

Alexandre Gianquinto commented

Yes, perfectly agree on both analysis and workaround (this is the workaround that I already had chosen). The blocking calls for the mappings is not a big issue as it is done at most once in a lifecycle

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 25, 2020

sothawo commented

This was implemented with DATAES-678

@spring-projects-issues spring-projects-issues added in: repository type: enhancement in: core labels Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core in: repository type: enhancement
Projects
None yet
Development

No branches or pull requests

1 participant