I am using spring-boot-starter-data-elasticsearch 2.1.0.RC1.
I have a custom query (via @Query annotation) where I want to pass 11 parameters. The query looks like this:
{
"bool" : {
"must" : [
{
"range" : {
"attribute0" : { "gte" : ?0, "lte" : ?1 }
}
},
{
"range" : {
"attribute1" : { "gte" : ?2, "lte" : ?3 }
}
},
{
"term": { "attribute2": "?4" }
},
{
"term": { "attribute3": "?5" }
},
{
"term": { "attribute4": "?6" }
},
{
"term": { "attribute5": "?7" }
},
{
"term": { "attribute6": "?8" }
},
{
"term": { "attribute7": "?9" }
},
{
"term": { "attribute8": "?10" }
}
]
}
}
In my repository, it looks like this:
@Query("{\"bool\":{\"must\":[{\"range\":{\"attribute0\":{\"gte\":?0,\"lte\":?1}}},{\"range\":{\"attribute1\":{\"gte\":?2,\"lte\":?3}}},{\"term\":{\"attribute2\":\"?4\"}},{\"term\":{\"attribute3\":\"?5\"}},{\"term\":{\"attribute4\":\"?6\"}},{\"term\":{\"attribute5\":\"?7\"}},{\"term\":{\"attribute6\":\"?8\"}},{\"term\":{\"attribute7\":\"?9\"}},{\"term\":{\"attribute8\":\"?10\"}}]}}")
Page<Entity> findAllByAttributes(
Integer param0, Integer param1,
Integer param2, Integer param3,
String param4, String param5,
String param6, String param7,
String param8, String param9,
String param10, Pageable pageable);
The problem is, I can't use more than 10 parameters (single digit index ?0 to ?9). The placeholder ?10 gets resolved to placeholder 1 with a zero appended.
I can't find anything in the Spring Data Elasticsearch reference documentation on any limitations in the number of parameters.
How can I pass more than 10 parameters into the @Query?
"\?(\d+)"(as can be seen here)