Question

I am trying to get a Spring Solr query using a repository

findByXOrYAndZ

The precedence should be as follows:

(X OR Y) AND Z

I am using a SolrCrudRepository but I guess any of the repo would work.

How can I enforce this?

Was it helpful?

Solution

You could annotate the repository method with a @Query and give an arbitrary query to it.

For example:

@Query("fieldA:?0 AND (fieldB:?1 OR fieldC:?2)")
Page<Document> findByXOrYAndZ(String par1, String par2, String par3);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top