Change index name to 'blog' and rename package to 'repository'
This commit is contained in:
parent
032be8319e
commit
68f33a2312
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue