I have this interface defined in Spring for querying Elascticsearch. I added @Query annotation to get some filtering done.
public interface ObjectElasticSearch extends ElasticsearchRepository<ElasticObject, String> {
@Query("{\"query\" : {\"filtered\" : {\"filter\" : { \"and\" : [ { \"term\" : { \"firstName\" : \":firstName\" }}, { \"term\" : { \"lastName\" : \"Baggins\" }} ] }}}}")
List<ElasticObject> findByDocFirstNameAndDocLastName(@Param("firstName") String firstName,
@Param("lastName") String lastName);
};
The @Query annotation gets ignored completely. As you can see I tried hardcoding last name, and it has no effect on the outcome of the query. If I delete a curly brace in the query string, I don't get any errors. Query still works, the filtering is ignored, and it returns all matches.
Can someone please help me figure out what am I doing wrong here.