{"id":13252,"date":"2013-05-31T10:10:09","date_gmt":"2013-05-31T07:10:09","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=13252"},"modified":"2013-05-31T10:04:29","modified_gmt":"2013-05-31T07:04:29","slug":"spring-data-solr-tutorial-dynamic-queries","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html","title":{"rendered":"Spring Data Solr Tutorial: Dynamic Queries"},"content":{"rendered":"<p>Solr is often referred as a search server which we can use when we are implementing full-text search functions. However, it is often wise to leverage the performance of Solr when we are implementing a search function which takes its input from a search form.<\/p>\n<p>In this scenario, the executed search query depends from the received input. This means that the number of query parameters depends from the input entered to the search form. In other words, the executed search query is dynamic.<\/p>\n<p>The <a href=\"http:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-adding-custom-methods-to-a-single-repository.html\">previous part of my Spring Data Solr tutorial<\/a> taught us how we can add custom methods to a single repository. It is time put this information in to use and find out how we can create dynamic queries with Spring Data Solr. Let\u2019s get started.<\/p>\n<p><strong>Note:<\/strong> These blog entries provide additional information which helps us to understand the concepts described in this blog post:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2013\/05\/running-solr-with-maven.html\">Running Solr with Maven<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-introduction-to-solr.html\">Spring Data Solr Tutorial: Introduction to Solr<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-configuration.html\">Spring Data Solr Tutorial: Configuration<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-crud-almost.html\">Spring Data Solr Tutorial CRUD (Almost)<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-adding-custom-methods-to-a-single-repository.html\">Spring Data Solr Tutorial: Adding Custom Methods to a Single Repository<\/a><\/li>\n<\/ul>\n<h2>Creating Dynamic Queries<\/h2>\n<p>This section describes how we can create dynamic queries with Spring Data Solr. It is divided into two subsections which are described in the following:<\/p>\n<ul>\n<li>The first subsection describes the basics which we need to know before we can start working on the actual search function.<\/li>\n<li>The second subsection describes how we can implement the search function of our example application by adding a custom method to our Spring Data Solr repository.<\/li>\n<\/ul>\n<h4>Learning the Basics<\/h4>\n<p>Before we can start implementing the search function of our example application, we need to know how we can create queries \u201cmanually\u201d by using Spring Data Solr. We can create a query \u201cmanually\u201d by following these steps:<\/p>\n<ol>\n<li>Create the search criteria.<\/li>\n<li>Create the query which holds the used search criteria.<\/li>\n<li>Execute the created query.<\/li>\n<\/ol>\n<p>These steps are described with more details in the following.<\/p>\n<h2>Creating the Search Criteria<\/h2>\n<p>First, we have to create the search criteria for our query. We can do this by using the criteria classes which are described in the following:<\/p>\n<ul>\n<li>The <a href=\"http:\/\/static.springsource.org\/spring-data\/solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/core\/query\/SimpleStringCriteria.html\" target=\"_blank\"><em>org.springframework.data.solr.core.query.SimpleStringCriteria<\/em><\/a> class is a basic criteria class which is used to specify the executed query by using already formatted query string. The query string specified in this class is executed as is. Thus, this class cannot be used to build dynamic queries.<\/li>\n<li>The <a href=\"http:\/\/static.springsource.org\/spring-data\/solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/core\/query\/Criteria.html\" target=\"_blank\"><em>org.springframework.data.solr.core.query.Criteria<\/em><\/a> is a criteria class which is used to build dynamic queries. It has a fluent API which supports the chaining of multiple <em>Criteria<\/em> objects.<\/li>\n<\/ul>\n<h2>Creating the Executed Query<\/h2>\n<p>Second, we have to create the executed query. The query classes of Spring Data Solr are described in the following:<\/p>\n<ul>\n<li>The <a href=\"http:\/\/static.springsource.org\/spring-data\/solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/core\/query\/SimpleQuery.html\" target=\"_blank\"><em>org.springframework.data.solr.core.query.SimpleQuery<\/em><\/a> class is a query class which supports both pagination and grouping.<\/li>\n<li>The <a href=\"http:\/\/static.springsource.org\/spring-data\/solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/core\/query\/SimpleFacetQuery.html\" target=\"_blank\"><em>org.springframework.data.solr.core.query.SimpleFacetQuery<\/em><\/a> class is a query class supporting <a href=\"http:\/\/wiki.apache.org\/solr\/SolrFacetingOverview\" target=\"_blank\">faceted search<\/a>.<\/li>\n<li>The <a href=\"http:\/\/static.springsource.org\/spring-data\/solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/core\/query\/SimpleFilterQuery.html\" target=\"_blank\"><em>org.springframework.data.solr.core.query.SimpleFilterQuery<\/em><\/a> class is query class which supports <a href=\"http:\/\/wiki.apache.org\/solr\/CommonQueryParameters#fq\" target=\"_blank\">filter queries<\/a>.<\/li>\n<\/ul>\n<h2>Executing the Created Query<\/h2>\n<p>Third, we have to execute the created query. The <a href=\"http:\/\/static.springsource.org\/spring-data\/solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/core\/SolrTemplate.html\" target=\"_blank\"><em>SolrTemplate<\/em><\/a> class implements several methods which we can use for this purpose. These methods are described in the following:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li>The <em>long count(final SolrDataQuery query)<\/em> method returns the number of documents found with the query given as a method parameter.<\/li>\n<li>The <em>UpdateResponse delete(SolrDataQuery query)<\/em> method deletes the documents which match with the query given as a method parameter and returns an <em>UpdateResponse<\/em> object.<\/li>\n<li>The <em>T queryForObject(Query query, Class&lt;T&gt; clazz)<\/em> method returns a single document which matches with the query given as a method parameter.<\/li>\n<li>The <em>FacetPage&lt;T&gt; queryForFacetPage(FacetQuery query, Class&lt;T&gt; clazz)<\/em> method executes a facet query against Solr index and returns the query results as a <a href=\"http:\/\/static.springsource.org\/spring-data\/solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/core\/query\/result\/FacetPage.html\" target=\"_blank\"><em>FacetPage<\/em><\/a> object.<\/li>\n<li>The <em>Page&lt;T&gt; queryForPage(Query query, Class&lt;T&gt; clazz)<\/em> method executes the query against Solr index and returns the query results as an implementation of the <a href=\"http:\/\/static.springsource.org\/spring-data\/data-commons\/docs\/current\/api\/org\/springframework\/data\/domain\/Page.html\" target=\"_blank\">Page<\/a> interface.<\/li>\n<\/ul>\n<p>Let\u2019s move on and put this theory into practice.<\/p>\n<h4>Implementing the Search Function<\/h4>\n<p>The requirements of our search function are following:<\/p>\n<ul>\n<li>The search function must return all todo entries which name or description contains some word of the given search term. In other words, if the search term is \u201cFoo Bar\u201d, our search function must return todo entries which title or description contains either \u201cFoo\u201d or \u201cBar\u201d.<\/li>\n<li>The search must be case insensitive.<\/li>\n<\/ul>\n<p>Because our search function is not static, we have to create it by using a dynamic query. We can create dynamic queries with Spring Data Solr by adding custom method to our Spring Data Solr repository. In other words, we have to follow these steps:<\/p>\n<ol>\n<li>Create a custom interface which declares the added method.<\/li>\n<li>Implement the created interface.<\/li>\n<li>Modify the repository interface to extend the created interface.<\/li>\n<\/ol>\n<p>These steps are described with more details in the following.<\/p>\n<h2>Creating the Custom Interface<\/h2>\n<p>First, we have to create a custom interface which declares our custom search method. We can do this by following these steps:<\/p>\n<ol>\n<li>Create an interface called <em>CustomTodoDocumentRepository<\/em>.<\/li>\n<li>Declare the <em>search()<\/em> method. This method takes the used search term as a method parameter and returns a list of <em>TodoDocument<\/em> objects.<\/li>\n<\/ol>\n<p>The source code of the <em>CustomTodoDocumentRepository<\/em> interface looks as follows:<\/p>\n<pre class=\"brush:java\">public interface CustomTodoDocumentRepository {\r\n\r\n    public List&lt;TodoDocument&gt; search(String searchTerm);\r\n\r\n    \/\/Other methods are omitted.\r\n}<\/pre>\n<h2>Implementing the Created Interface<\/h2>\n<p>Second, we have to implement the custom interface which we created earlier. We can do this by following these steps:<\/p>\n<ol>\n<li>Create a class called <em>TodoDocumentRepositoryImpl<\/em> and implement the <em>CustomTodoDocumentRepository<\/em> interface.<\/li>\n<li>Annotate the class with the <em>@Repository<\/em> annotation.<\/li>\n<li>Add <em>SolrTemplate<\/em> field to the class and annotate it with the <em>@Resource<\/em> annotation.<\/li>\n<li>Implement the <em>search()<\/em> method.<\/li>\n<\/ol>\n<p>The implementation of the <em>search()<\/em> method requires a more detailed description which is given here. We can implement the <em>search()<\/em> method by following these steps:<\/p>\n<ol>\n<li>Get the words of the search term.<\/li>\n<li>Construct the used search criteria by calling the private <em>createSearchConditions()<\/em> method and passing the words of the search term as a method parameter. This method creates the used search criteria by using the API of the <em>Criteria<\/em> class.<\/li>\n<li>Create the executed query by creating a new <em>SimpleQuery<\/em> object and pass the created <em>Criteria<\/em> object as a constructor parameter.<\/li>\n<li>Get the search results by calling the <em>queryForPage()<\/em> method of the <em>SolrTemplate<\/em> class. Pass the created query and the type of the expected result objects as method parameters.<\/li>\n<li>Return the search results by calling the <em>getContent()<\/em> method of the <em>Page<\/em> interface.<\/li>\n<\/ol>\n<p>The source code of the <em>TodoDocumentRepositoryImpl<\/em> class looks as follows:<\/p>\n<pre class=\"brush:java\">import org.springframework.data.domain.Page;\r\nimport org.springframework.data.solr.core.SolrTemplate;\r\nimport org.springframework.data.solr.core.query.Criteria;\r\nimport org.springframework.data.solr.core.query.SimpleQuery;\r\nimport org.springframework.stereotype.Repository;\r\n\r\nimport javax.annotation.Resource;\r\n\r\n@Repository\r\npublic class TodoDocumentRepositoryImpl implements CustomTodoDocumentRepository {\r\n\r\n    @Resource\r\n    private SolrTemplate solrTemplate;\r\n\r\n    @Override\r\n    public List&lt;TodoDocument&gt; search(String searchTerm) {\r\n        String[] words = searchTerm.split(\" \");\r\n\r\n        Criteria conditions = createSearchConditions(words);\r\n        SimpleQuery search = new SimpleQuery(conditions);\r\n\r\n        Page results = solrTemplate.queryForPage(search, TodoDocument.class);\r\n        return results.getContent();\r\n    }\r\n\r\n    private Criteria createSearchConditions(String[] words) {\r\n        Criteria conditions = null;\r\n\r\n        for (String word: words) {\r\n            if (conditions == null) {\r\n                conditions = new Criteria(\u201ctitle\u201d).contains(word)\r\n                        .or(new Criteria(\u201cdescription\u201d).contains(word));\r\n            }\r\n            else {\r\n                conditions = conditions.or(new Criteria(\u201ctitle\u201d).contains(word))\r\n                        .or(new Criteria(\u201cdescription\u201d).contains(word));\r\n            }\r\n        }\r\n\r\n        return conditions;\r\n    }\r\n\r\n    \/\/Other methods are omitted\r\n}<\/pre>\n<h2>Modifying the Repository Interface<\/h2>\n<p>Third, we have to make our custom <em>search()<\/em> method visible to the users of our repository. We can do this by extending the <em>CustomTodoDocumentRepository<\/em> interface. The source code of the <em>TodoDocumentRepository<\/em> interface looks as follows:<\/p>\n<pre class=\"brush:java\">import org.springframework.data.solr.repository.SolrCrudRepository;\r\n\r\npublic interface TodoDocumentRepository extends CustomTodoDocumentRepository, SolrCrudRepository&lt;TodoDocument, String&gt; {\r\n\r\n}<\/pre>\n<p>We have now added a custom <em>search()<\/em> method to our Spring Data Solr repository. Let\u2019s find out how we can use this method.<\/p>\n<h2>Using the Custom Method<\/h2>\n<p>We can use the custom method by modifying the <em>search()<\/em> method of the <em>RepositoryTodoIndexService<\/em> class. The new implementation of this method is very simple. It gets the search results by calling the <em>search()<\/em> method of our Spring Data Solr repository and returns the search results.<\/p>\n<p>The source code of the <em>RepositoryTodoIndexService<\/em> class looks as follows:<\/p>\n<pre class=\"brush:java\">import org.springframework.stereotype.Service;\r\n\r\nimport javax.annotation.Resource;\r\nimport java.util.List;\r\n\r\n@Service\r\npublic class RepositoryTodoIndexService implements TodoIndexService {\r\n\r\n    @Resource\r\n    private TodoDocumentRepository repository;\r\n\r\n    \/\/Other methods are omitted.\r\n\r\n    @Override\r\n    public List&lt;TodoDocument&gt; search(String searchTerm) {\r\n        return repository.search(searchTerm);\r\n    }\r\n}<\/pre>\n<h2>Summary<\/h2>\n<p>We have now implemented a dynamic search function with Spring Data Solr. Although our search function was rather simple, we should now be able to implement more complex queries as well.<\/p>\n<p>This tutorial has taught us two things:<\/p>\n<ul>\n<li>We learned how we can create queries \u201cmanually\u201d by using Spring Data Solr.<\/li>\n<li>We learned that we have to implement dynamic search methods by adding custom method to a single repository.<\/li>\n<\/ul>\n<p>The next part of my Spring Data Solr tutorial describes how we can sort our query results.<\/p>\n<p>P.S. The example application of this blog post is available <a href=\"https:\/\/github.com\/pkainulainen\/spring-data-solr-examples\/tree\/master\/criteria\" target=\"_blank\">at Github<\/a>.<br \/>\n&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/www.petrikainulainen.net\/programming\/solr\/spring-data-solr-tutorial-dynamic-queries\/\">Spring Data Solr Tutorial: Dynamic Queries<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Petri Kainulainen at the <a href=\"http:\/\/www.petrikainulainen.net\/\">Petri Kainulainen<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Solr is often referred as a search server which we can use when we are implementing full-text search functions. However, it is often wise to leverage the performance of Solr when we are implementing a search function which takes its input from a search form. In this scenario, the executed search query depends from the &hellip;<\/p>\n","protected":false},"author":429,"featured_media":80,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[470,30,321],"class_list":["post-13252","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-apache-solr","tag-spring","tag-spring-data"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Data Solr Tutorial: Dynamic Queries<\/title>\n<meta name=\"description\" content=\"Solr is often referred as a search server which we can use when we are implementing full-text search functions. However, it is often wise to leverage the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Data Solr Tutorial: Dynamic Queries\" \/>\n<meta property=\"og:description\" content=\"Solr is often referred as a search server which we can use when we are implementing full-text search functions. However, it is often wise to leverage the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-05-31T07:10:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-solr-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Petri Kainulainen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/petrikainulaine\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Petri Kainulainen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html\"},\"author\":{\"name\":\"Petri Kainulainen\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5af4df3fdfeb79e9fa3598d79bff2c9e\"},\"headline\":\"Spring Data Solr Tutorial: Dynamic Queries\",\"datePublished\":\"2013-05-31T07:10:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html\"},\"wordCount\":1334,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-solr-logo.jpg\",\"keywords\":[\"Apache Solr\",\"Spring\",\"Spring Data\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html\",\"name\":\"Spring Data Solr Tutorial: Dynamic Queries\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-solr-logo.jpg\",\"datePublished\":\"2013-05-31T07:10:09+00:00\",\"description\":\"Solr is often referred as a search server which we can use when we are implementing full-text search functions. However, it is often wise to leverage the\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-solr-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-solr-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-dynamic-queries.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Data Solr Tutorial: Dynamic Queries\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5af4df3fdfeb79e9fa3598d79bff2c9e\",\"name\":\"Petri Kainulainen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g\",\"caption\":\"Petri Kainulainen\"},\"description\":\"Petri is passionate about software development and continuous improvement. He is specialized in software development with the Spring Framework and is the author of Spring Data book.\",\"sameAs\":[\"http:\\\/\\\/www.petrikainulainen.net\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/petrikainulainen\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/petrikainulaine\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/petri-kainulainen\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Data Solr Tutorial: Dynamic Queries","description":"Solr is often referred as a search server which we can use when we are implementing full-text search functions. However, it is often wise to leverage the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html","og_locale":"en_US","og_type":"article","og_title":"Spring Data Solr Tutorial: Dynamic Queries","og_description":"Solr is often referred as a search server which we can use when we are implementing full-text search functions. However, it is often wise to leverage the","og_url":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-05-31T07:10:09+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-solr-logo.jpg","type":"image\/jpeg"}],"author":"Petri Kainulainen","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/petrikainulaine","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Petri Kainulainen","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html"},"author":{"name":"Petri Kainulainen","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5af4df3fdfeb79e9fa3598d79bff2c9e"},"headline":"Spring Data Solr Tutorial: Dynamic Queries","datePublished":"2013-05-31T07:10:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html"},"wordCount":1334,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-solr-logo.jpg","keywords":["Apache Solr","Spring","Spring Data"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html","url":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html","name":"Spring Data Solr Tutorial: Dynamic Queries","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-solr-logo.jpg","datePublished":"2013-05-31T07:10:09+00:00","description":"Solr is often referred as a search server which we can use when we are implementing full-text search functions. However, it is often wise to leverage the","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-solr-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-solr-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-dynamic-queries.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Data Solr Tutorial: Dynamic Queries"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5af4df3fdfeb79e9fa3598d79bff2c9e","name":"Petri Kainulainen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g","caption":"Petri Kainulainen"},"description":"Petri is passionate about software development and continuous improvement. He is specialized in software development with the Spring Framework and is the author of Spring Data book.","sameAs":["http:\/\/www.petrikainulainen.net\/","http:\/\/www.linkedin.com\/in\/petrikainulainen","https:\/\/x.com\/https:\/\/twitter.com\/petrikainulaine"],"url":"https:\/\/www.javacodegeeks.com\/author\/petri-kainulainen"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/13252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/429"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=13252"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/13252\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/80"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=13252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=13252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=13252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}