christophstrobl / spring-data-solr-showcase

Sample Spring MVC Application demonstrating usage of Spring Data Solr.
Apache License 2.0
95 stars 85 forks source link

@Query params #8

Open walshe opened 8 years ago

walshe commented 8 years ago

Hi, I am facing a problem with a @Query that has over 10 params, wondering i you could help

The problem is that when spring is doing the placeholder replacement it is starting at ?0, ?1, ?2 etc (in AbstractSolrQuery.replacePlaceholders(..))

so when it is processing '?1' it ends up writing over my ?10 placeholder which hasnt been processed yet

thus my 10th param ends up with a value of "param1value0"

is there a way around this ? If replacePlaceholders could start at the higher positions first it would work but dont think i can override this easily

@Highlight(prefix = "<b>", postfix = "</b>")
@Query("""text:( ?0 ) AND moduleLevel_s:( ?1 ) AND programOfStudy_s:?2 AND yearOfEntry_i:?3 AND yearOfStudy_i:?4 AND unitValue_d:?5 AND department_s:( ?6 ) AND teachers_ss:( ?7 ) AND cappedAccess_b:?8 AND terms_ss:( ?9 ) AND days_ss:( ?10 )""")
HighlightPage<CourseGuide> advancedSearch(@Param(value = "query") List<String> query,
                                 @Param(value = "moduleLevel") List<ModuleLevel> moduleLevel,
                                 @Param(value = "programOfStudy") String programOfStudy,
                                 @Param(value = "yearOfEntry") def yearOfEntry,
                                 @Param(value = "yearOfStudy") def yearOfStudy,
                                 @Param(value = "unitValue") def unitValue,
                                 @Param(value = "department") List<String> department,
                                 @Param(value = "teachers") List<String> teachers,
                                 @Param(value = "cappedAccess") def cappedAccess,
                                 @Param(value = "terms") List<String> terms,
                                 @Param(value = "days") List<String> days,
                                 Pageable pageable)