I started learning Elasticsearch recently, have watched already a couple of videos about this technology and noticed that we mark fields in the method’s parameters as final. Simultaneously, we don’t mark parameters with this keyword when use MySQL, for the instance.
Why? Because there are no field locks and transactions inside of Elasticsearch unlike MySQL?
For example:
Let’s suppose that we have a REST controller for users in our app and a method that return user based on its id inside of this controller.
In the case when we use MySQL:
@GetMapping(“/user/{id}”)
public User getUserById(@ParhVariable Long id) {
return userRepository.getById(id).orElse(null);
}
In the case when we use Elasticsearch:
@GetMapping(“/user/{id}”)
public User getUserById(@ParhVariable final Long id) {
return userRepository.getById(id).orElse(null);
}