Change index name to 'blog' and rename package to 'repository'

This commit is contained in:
Dmitry Zinkevich 2016-02-04 15:10:06 +03:00
parent 032be8319e
commit 68f33a2312
4 changed files with 18 additions and 3 deletions

View File

@ -17,7 +17,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.baeldung.dao")
@EnableElasticsearchRepositories(basePackages = "com.baeldung.repository")
@ComponentScan(basePackages = {"com.baeldung.service"})
public class Config {

View File

@ -8,7 +8,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.List;
@Document(indexName = "article", type = "article")
@Document(indexName = "blog", type = "article")
public class Article {
@Id

View File

@ -0,0 +1,15 @@
package com.baeldung.repository;
import com.baeldung.model.Article;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
public interface ArticleRepository extends ElasticsearchRepository<Article, String> {
Page<Article> findByAuthorsName(String name, Pageable pageable);
@Query("{\"bool\": {\"must\": [{\"match\": {\"authors.name\": \"?0\"}}]}}")
Page<Article> findByAuthorsNameUsingCustomQuery(String name, Pageable pageable);
}

View File

@ -1,6 +1,6 @@
package com.baeldung.service;
import com.baeldung.dao.ArticleRepository;
import com.baeldung.repository.ArticleRepository;
import com.baeldung.model.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;