{"id":13188,"date":"2013-05-24T19:00:53","date_gmt":"2013-05-24T16:00:53","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=13188"},"modified":"2013-05-24T10:33:38","modified_gmt":"2013-05-24T07:33:38","slug":"spring-data-solr-tutorial-query-methods","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html","title":{"rendered":"Spring Data Solr Tutorial: Query Methods"},"content":{"rendered":"<p>We have learned how we can configure Spring Data Solr. We have also learned how we can add new documents to the Solr index, update the information of existing documents and delete documents from the Solr index. Now it is time to move forward and learn how we can search information from the Solr index by using Spring Data Solr. The requirements of our search function are given in the following:<\/p>\n<ul>\n<li>The search function must return all todo entries which title or description contains the given search term.<\/li>\n<li>The search must be case insensitive.<\/li>\n<\/ul>\n<p>We can implement the search function by following these steps:<\/p>\n<ol>\n<li>Create a query method.<\/li>\n<li>Use the created query method.<\/li>\n<\/ol>\n<p>Let\u2019s move on and find out how we can implement the search function by using query methods.<\/p>\n<p><strong>Note:<\/strong> These blog entries provide additional information which helps us the understand the concepts described in this blog entry:<\/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<\/ul>\n<h2>Creating the Query Method<\/h2>\n<p>Query methods are methods which are<\/p>\n<ol>\n<li>added to the repository interface.<\/li>\n<li>used to specify the search query which is executed when the query method is called.<\/li>\n<li>used to build static queries (queries which have always the same amount of query parameters).<\/li>\n<\/ol>\n<p>We can create query methods with Spring Data Solr by using the following techniques:<\/p>\n<ul>\n<li>Query generation from the method name<\/li>\n<li>Named queries<\/li>\n<li>@Query annotation<\/li>\n<\/ul>\n<p>These techniques are described with more details in the following subsections.<\/p>\n<h4>Query Generation from the Method Name<\/h4>\n<p>The query generation from the method name is a query generation strategy where the executed query is parsed from the name of the query method.<\/p>\n<ol>\n<li>The name of the query method must start with a special prefix which identifies the query method. These prefixes are: <em>find, findBy, get, getBy, read and readBy<\/em>. This prefix is stripped from the method name when the executed query is parsed.<\/li>\n<li>Property expressions are used to refer to the properties of our document class.<\/li>\n<li>Special keywords are used together with property expressions to specify the operators used in the created query. These keywords are added to the name of the query method after a property expression.<\/li>\n<li>We can combine property expressions by adding either <em>And<\/em> or <em>Or<\/em> keyword between them.<\/li>\n<li>The parameter count of the query method must be equal with the number of property expressions used in its name.<\/li>\n<\/ol>\n<p>We can get more information about the property expressions and the repository keywords by reading the following resources:<\/p>\n<ul>\n<li><a href=\"http:\/\/static.springsource.org\/spring-data\/data-solr\/docs\/1.0.0.RC1\/reference\/htmlsingle\/#repositories.query-methods.query-creation\" target=\"_blank\">Spring Data Solr Reference Manual: Query Creation<\/a><\/li>\n<li><a href=\"http:\/\/static.springsource.org\/spring-data\/data-solr\/docs\/1.0.0.RC1\/reference\/htmlsingle\/#repository-query-keywords\" target=\"_blank\">Spring Data Solr Reference Manual: Repository Query Keywords<\/a><\/li>\n<\/ul>\n<p>As we remember, our search function must return all todo entries which title or description contains the given search term. Also, our document class has two properties which we are using in this query. These properties are called <em>title<\/em> and <em>description<\/em>. We can create the method name which fulfils the requirements of our search function by following these steps:<\/p>\n<ol>\n<li>Add the <em>findBy<\/em> prefix to start of the method name.<\/li>\n<li>Add the property expression of the <em>title<\/em> property after the prefix.<\/li>\n<li>Add the <em>Contains<\/em> keyword after the property expression.<\/li>\n<li>Add the <em>Or<\/em> keyword to the method name.<\/li>\n<li>Add the property expression of the <em>description<\/em> property after the <em>Or<\/em> keyword.<\/li>\n<li>Add the <em>Contains<\/em> keyword to the method name.<\/li>\n<li>Add two method parameters to our query method. The first parameter matched against the <em>title<\/em> property and second one is matched against the <em>description<\/em> property.<\/li>\n<\/ol>\n<p>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\nimport java.util.List;\r\n\r\npublic interface TodoDocumentRepository extends SolrCrudRepository&lt;TodoDocument, String&gt; {\r\n\r\n    public List&lt;TodoDocument&gt; findByTitleContainsOrDescriptionContains(String title, String description);\r\n}<\/pre>\n<p><strong>Note:<\/strong> This query method will not work if the search term contains more than one word.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h4>Named Queries<\/h4>\n<p>Named queries are queries which are declared in a separate properties file and wired to the correct query method. The rules concerning the properties file used to declare the named queries are described in the following:<\/p>\n<ul>\n<li>The default location of the properties file is <em>META-INF\/solr-named-queries.properties<\/em> but we can configure the location by using the <em>namedQueriesLocation<\/em> property of the <a href=\"http:\/\/static.springsource.org\/spring-data\/data-solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/repository\/config\/EnableSolrRepositories.html\" target=\"_blank\"><em>@EnableSolrRepositories<\/em> annotation<\/a>.<\/li>\n<li>The key of each named query is created by using the following formula: <em>[The name of the document class].[The name of the named query]<\/em>.<\/li>\n<\/ul>\n<p>Named queries which are configured in the properties files are matched with the query methods of our repository interface by using the following rules:<\/p>\n<ul>\n<li>The name of query method which executes the named query must be same than the name of the named query.<\/li>\n<li>If the name of the query method is not the same than the name of the named query, the query method must be annotated with the <a href=\"http:\/\/static.springsource.org\/spring-data\/data-solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/repository\/Query.html\" target=\"_blank\"><em>@Query<\/em> annotation<\/a> and the name of the named query must be configured by using the <em>name<\/em> property of the <em>@Query<\/em> annotation.<\/li>\n<\/ul>\n<p>We can implement query method with named queries by following these steps:<\/p>\n<ol>\n<li>Specify the named query.<\/li>\n<li>Create the query method.<\/li>\n<\/ol>\n<p>These steps are described with more details in the following.<\/p>\n<h4>Specifying the Named Query<\/h4>\n<p>We can create a named query which fulfils the requirements of our search function by following these steps:<\/p>\n<ol>\n<li>Create the properties file which contains the named queries.<\/li>\n<li>Create a key for the named query by using the formula described earlier. Since the name of our document class is <em>TodoDocument<\/em>, the key of our named query is <em>TodoDocument.findByNamedQuery<\/em>.<\/li>\n<li>Create the named query by using the <a href=\"http:\/\/wiki.apache.org\/solr\/SolrQuerySyntax#Default_QParserPlugin:_LuceneQParserPlugin\" target=\"_blank\">Lucene query parser syntax<\/a>. Because our query must return documents which title or description contains the given search term, our query is: <em>title:*?0* OR description:*?0*<\/em> (The <em>?0<\/em> is replaced with the value of the query method\u2019s first parameter).<\/li>\n<\/ol>\n<p>The content of the <em>META-INF\/solr-named-query.properties<\/em> file looks as follows:<\/p>\n<pre class=\"brush:java\">TodoDocument.findByNamedQuery=title:*?0* OR description:*?0*<\/pre>\n<h2>Creating the Query Method<\/h2>\n<p>We can create the query method which uses the created named query by following these steps:<\/p>\n<ol>\n<li>Add <em>findByNamedQuery()<\/em> method to the <em>TodoDocumentRepository<\/em> interface. This method returns a list of <em>TodoDocument<\/em> objects and takes a single <em>String<\/em> parameter called <em>searchTerm<\/em>.<\/li>\n<li>Annotate the method with the <em>@Query<\/em> annotation and set the value of its <em>name<\/em> property to \u2018TodoDocument.findByNamedQuery\u2019. This step is not required since the name of the query method is the same than the name of the named query but I wanted to demonstrate the usage of the <em>@Query<\/em> annotation here.<\/li>\n<\/ol>\n<p>The source code of the <em>TodoDocumentRepository<\/em> interface looks as follows:<\/p>\n<pre class=\"brush:java\">import org.springframework.data.solr.repository.Query;\r\nimport org.springframework.data.solr.repository.SolrCrudRepository;\r\n\r\nimport java.util.List;\r\n\r\npublic interface TodoDocumentRepository extends SolrCrudRepository&lt;TodoDocument, String&gt; {\r\n\r\n    @Query(name = \"TodoDocument.findByNamedQuery\")\r\n    public List&lt;TodoDocument&gt; findByNamedQuery(String searchTerm);\r\n}<\/pre>\n<h4>@Query Annotation<\/h4>\n<p>The <a href=\"http:\/\/static.springsource.org\/spring-data\/data-solr\/docs\/1.0.0.RC1\/api\/org\/springframework\/data\/solr\/repository\/Query.html\" target=\"_blank\"><em>@Query<\/em> annotation<\/a> can be used to specify the query which is executed when a query method is called. We can create the query method which fulfils the requirements of our search function by following these steps:<\/p>\n<ol>\n<li>Add <em>findByQueryAnnotation()<\/em> method to the <em>TodoDocumentRepository<\/em> interface. This method returns a list of <em>TodoDocument<\/em> objects and it has a single <em>String<\/em> parameter called <em>searchTerm<\/em>.<\/li>\n<li>Annotate the method with the <em>@Query<\/em> annotation.<\/li>\n<li>Set the executed query as the value of the <em>@Query<\/em> annotation. We can create the query by using the <a href=\"http:\/\/wiki.apache.org\/solr\/SolrQuerySyntax#Default_QParserPlugin:_LuceneQParserPlugin\" target=\"_blank\">Lucene query parser syntax<\/a>. Because our query must return documents which title or description contains the given search term, the correct query is: <em>title:*?0* OR description:*?0*<\/em> (The <em>?0<\/em> is replaced with the value of the query method\u2019s first parameter).<\/li>\n<\/ol>\n<p>The source code of the <em>TodoDocumentRepository<\/em> interface looks as follows:<\/p>\n<pre class=\"brush:java\">import org.springframework.data.solr.repository.Query;\r\nimport org.springframework.data.solr.repository.SolrCrudRepository;\r\n\r\nimport java.util.List;\r\n\r\npublic interface TodoDocumentRepository extends SolrCrudRepository&lt;TodoDocument, String&gt; {\r\n\r\n    @Query(\"title:*?0* OR description:*?0*\")\r\n    public List&lt;TodoDocument&gt; findByQueryAnnotation(String searchTerm);\r\n}<\/pre>\n<h2>Using the Created Query Method<\/h2>\n<p>We can use the created query method by following these steps:<\/p>\n<ol>\n<li>Declare the <em>search()<\/em> method in the <em>TodoIndexService<\/em> interface.<\/li>\n<li>Add the implementation of the <em>search()<\/em> method to the <em>RepositoryTodoIndexService<\/em> class.<\/li>\n<\/ol>\n<p>These steps are described with more details in the following subsections.<\/p>\n<h4>Declaring the Search Method<\/h4>\n<p>Our first step is to declare the search method in the <em>TodoIndexService<\/em> interface. The relevant part of the <em>TodoIndexService<\/em> interface looks as follows:<\/p>\n<pre class=\"brush:java\">import java.util.List;\r\n\r\npublic interface TodoIndexService {\r\n\r\n    public List&lt;TodoDocument&gt; search(String searchTerm);\r\n}<\/pre>\n<h4>Implementing the Search Method<\/h4>\n<p>Our second step is to implement the <em>search()<\/em> method. Our implementation is rather simple. It obtains a list of <em>TodoDocument<\/em> objects by calling the correct method of the <em>TodoDocumentRepository<\/em> interface and returns that list.<\/p>\n<p>The name of the query method depends from the technique used to create the query method. The different implementations are described in the following.<\/p>\n<h4>Query Generation from the Method Name<\/h4>\n<p>When we are generating the query from the name of the query method, our implementation obtains a list of <em>TodoDocument<\/em> objects by calling the <em>findByTitleContainsOrDescriptionContains()<\/em> method of the <em>TodoDocumentRepository<\/em> interface and returns that list.<\/p>\n<p>The relevant part of the <em>RepositoryTodoIndexService<\/em> class looks as follows:<\/p>\n<pre class=\"brush:java\">import org.springframework.stereotype.Service;\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    @Override\r\n    public List&lt;TodoDocument&gt; search(String searchTerm) {\r\n        return repository.findByTitleContainsOrDescriptionContains(searchTerm, searchTerm);\r\n    }\r\n}<\/pre>\n<h4>Named Queries<\/h4>\n<p>If we are using named queries, our implementation gets a list of <em>TodoDocument<\/em> objects by calling the <em>findByNamedQuery()<\/em> method of the <em>TodoDocumentRepository<\/em> interface and returns that list.<\/p>\n<p>The relevant part of the <em>RepositoryTodoIndexService<\/em> class looks as follows:<\/p>\n<pre class=\"brush:java\">import org.springframework.stereotype.Service;\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    @Override\r\n    public List&lt;TodoDocument&gt; search(String searchTerm) {\r\n        return repository.findByNamedQuery(searchTerm);\r\n    }\r\n}<\/pre>\n<h4>@Query Annotation<\/h4>\n<p>When we are using the <em>@Query<\/em> annotation, our implementation obtains a list of <em>TodoDocument<\/em> objects by calling the <em>findByQueryAnnotation()<\/em> method of the <em>TodoDocumentRepository<\/em> interface and returns that list.<\/p>\n<p>The relevant part of the <em>RepositoryTodoIndexService<\/em> class looks as follows:<\/p>\n<pre class=\"brush:java\">import org.springframework.stereotype.Service;\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    @Override\r\n    public List&lt;TodoDocument&gt; search(String searchTerm) {\r\n        return repository.findByQueryAnnotation(searchTerm);\r\n    }\r\n}<\/pre>\n<h2>Selecting the Correct Query Creation Technique<\/h2>\n<p>The obvious question is:<\/p>\n<p>What is the best way to add query methods to our Spring Data Solr repositories?<\/p>\n<p>We can use the following guidelines when we are deciding the correct query creation technique for our query method:<\/p>\n<ul>\n<li>If the created query is very simple, query generation from the method name is often the best choice. The problem of this approach is that implementing \u201ccomplex\u201d queries with this approach leads into long and ugly method names.<\/li>\n<li>It is a good idea to keep our queries near our query methods. The benefit of using the <em>@Query<\/em> annotation is that we can see the executed query and our query method by reading the source code of our repository interface.<\/li>\n<li>If we want to separate the executed queries from our repository interface, we should use named queries. The problem of this approach is that we have to check the executed query from the properties file which is quite cumbersome.<\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>We have now learned how we can create static queries with Spring Data Solr. This blog entry has taught us two things:<\/p>\n<ul>\n<li>We know what query method methods are and how we can create them.<\/li>\n<li>We are familiar with the different query creation techniques and we know when to use them.<\/li>\n<\/ul>\n<p>The example application which demonstrates the concepts described in this blog entry is available at <a href=\"https:\/\/github.com\/pkainulainen\/spring-data-solr-examples\/tree\/master\/query-methods\" target=\"_blank\">Github<\/a>. In the next part of this tutorial we will learn <a href=\"http:\/\/www.petrikainulainen.net\/programming\/solr\/spring-data-solr-tutorial-adding-custom-methods-to-a-single-repository\/\">how we can add custom functionality to a single repository<\/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-query-methods\/\">Spring Data Solr Tutorial: Query Methods<\/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>We have learned how we can configure Spring Data Solr. We have also learned how we can add new documents to the Solr index, update the information of existing documents and delete documents from the Solr index. Now it is time to move forward and learn how we can search information from the Solr index &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-13188","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: Query Methods<\/title>\n<meta name=\"description\" content=\"We have learned how we can configure Spring Data Solr. We have also learned how we can add new documents to the Solr index, update the information of\" \/>\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-query-methods.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: Query Methods\" \/>\n<meta property=\"og:description\" content=\"We have learned how we can configure Spring Data Solr. We have also learned how we can add new documents to the Solr index, update the information of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.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-24T16:00:53+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=\"10 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-query-methods.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.html\"},\"author\":{\"name\":\"Petri Kainulainen\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5af4df3fdfeb79e9fa3598d79bff2c9e\"},\"headline\":\"Spring Data Solr Tutorial: Query Methods\",\"datePublished\":\"2013-05-24T16:00:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.html\"},\"wordCount\":1713,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.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-query-methods.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.html\",\"name\":\"Spring Data Solr Tutorial: Query Methods\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-solr-logo.jpg\",\"datePublished\":\"2013-05-24T16:00:53+00:00\",\"description\":\"We have learned how we can configure Spring Data Solr. We have also learned how we can add new documents to the Solr index, update the information of\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/05\\\/spring-data-solr-tutorial-query-methods.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-query-methods.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: Query Methods\"}]},{\"@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: Query Methods","description":"We have learned how we can configure Spring Data Solr. We have also learned how we can add new documents to the Solr index, update the information of","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-query-methods.html","og_locale":"en_US","og_type":"article","og_title":"Spring Data Solr Tutorial: Query Methods","og_description":"We have learned how we can configure Spring Data Solr. We have also learned how we can add new documents to the Solr index, update the information of","og_url":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-05-24T16:00:53+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":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html"},"author":{"name":"Petri Kainulainen","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5af4df3fdfeb79e9fa3598d79bff2c9e"},"headline":"Spring Data Solr Tutorial: Query Methods","datePublished":"2013-05-24T16:00:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html"},"wordCount":1713,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.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-query-methods.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html","url":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html","name":"Spring Data Solr Tutorial: Query Methods","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-solr-logo.jpg","datePublished":"2013-05-24T16:00:53+00:00","description":"We have learned how we can configure Spring Data Solr. We have also learned how we can add new documents to the Solr index, update the information of","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/05\/spring-data-solr-tutorial-query-methods.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-query-methods.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: Query Methods"}]},{"@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\/13188","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=13188"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/13188\/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=13188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=13188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=13188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}