Last time we covered Solr CRUD operations in Spring Data Solr. Today we’re going to begin a series on Custom Solr Query types, beginning with the Java Criteria API.
Here’s a quick definition of Criteria Queries:
Criteria queries are a programmatic, type-safe way to express a query. They are type-safe in terms of using interfaces and classes to represent various structural parts of a query. (source)
We begin in our SolrUI class, passing the following query to our ProductService.
Notice how we’re using the Product Class fields to build the query. We’ll be saving it as a Criteria object called conditions. By the way, that’s a Solr Criteria object.
Here’s the Solr query we built with “Canon Camera memory.”
And our output.
As usual, all of the source code covered in this post is available in NixMash Spring on GitHub.