diff --git a/src/main/java/at/ac/uibk/gitsearch/repository/search/MetaDataRepository.java b/src/main/java/at/ac/uibk/gitsearch/repository/search/MetaDataRepository.java index a7fb604091877d4c22b89997d855e7cae94bc4f3..45aae2199ea1d4f409033c5879ef0fa9c5487bea 100644 --- a/src/main/java/at/ac/uibk/gitsearch/repository/search/MetaDataRepository.java +++ b/src/main/java/at/ac/uibk/gitsearch/repository/search/MetaDataRepository.java @@ -223,9 +223,15 @@ public class MetaDataRepository { term -> queryBuilder.must(QueryBuilders.prefixQuery(SearchRepositoryConstants.METADATA_KEYWORDS, term))); - forEachTerm(searchInputDTO.getMetadata().getAuthor(), - term -> - queryBuilder.must(QueryBuilders.prefixQuery(SearchRepositoryConstants.METADATA_CREATOR, term))); + if(searchInputDTO.getMetadata().getAuthor()!=null) + queryBuilder.must(QueryBuilders.multiMatchQuery(searchInputDTO.getMetadata().getAuthor(), + SearchRepositoryConstants.METADATA_CREATOR, + SearchRepositoryConstants.METADATA_CONTRIBUTOR, + SearchRepositoryConstants.METADATA_PUBLISHER).type(MultiMatchQueryBuilder.Type.PHRASE_PREFIX)); + +// forEachTerm(searchInputDTO.getMetadata().getAuthor(), +// term -> +// queryBuilder.must(QueryBuilders.prefixQuery(SearchRepositoryConstants.METADATA_CREATOR, term))); forEachTerm(searchInputDTO.getMetadata().getLicense(), term -> diff --git a/src/main/java/at/ac/uibk/gitsearch/repository/search/SearchRepositoryConstants.java b/src/main/java/at/ac/uibk/gitsearch/repository/search/SearchRepositoryConstants.java index 8dffd62300b6189c1807a4458e58e6c8ba54bd03..f706accf727857388c5af01b39f7d29e4f124aef 100644 --- a/src/main/java/at/ac/uibk/gitsearch/repository/search/SearchRepositoryConstants.java +++ b/src/main/java/at/ac/uibk/gitsearch/repository/search/SearchRepositoryConstants.java @@ -21,5 +21,6 @@ public final class SearchRepositoryConstants { public static final String METADATA_PROJECT_ID = "project.project_id"; public static final String METADATA_CREATOR = "metadata.creator.name"; public static final String METADATA_CONTRIBUTOR = "metadata.contributor.name"; + public static final String METADATA_PUBLISHER = "metadata.publisher.name"; public static final String METADATA_LICENSE = "metadata.license"; } diff --git a/src/test/java/at/ac/uibk/gitsearch/service/SearchServiceIT.java b/src/test/java/at/ac/uibk/gitsearch/service/SearchServiceIT.java index e1397ec6c002b3ffe018c13798554c9439057d1f..cc6ad6bcfb32e2d18f23eb7ef080c87adce5e881 100644 --- a/src/test/java/at/ac/uibk/gitsearch/service/SearchServiceIT.java +++ b/src/test/java/at/ac/uibk/gitsearch/service/SearchServiceIT.java @@ -56,6 +56,23 @@ public class SearchServiceIT { } + @Test + public void testSearchByAutor() throws Exception { + final String PODLIPNIG = "Stefan Podlipnig"; + final SearchInputMetadataDTO searchMetadata = + new SearchInputMetadataDTO(null, null, null, null, PODLIPNIG); + SearchInputDTO searchQuery = + new SearchInputDTO(null, searchMetadata, null, null, null, 0); + SearchResultsDTO searchResultPage = + searchService.searchResultPage(searchQuery, 0, SearchInputDTO.PAGE_SIZE); + + org.junit.Assert.assertNotNull(searchResultPage.getSearchResult()); + org.junit.Assert.assertTrue("At least one test hit", searchResultPage.getHitCount() >= 1); + org.junit.Assert.assertThat(searchResultPage.getSearchResult(), everyItem( + hasProperty("creator", hasProperty("name", containsString(PODLIPNIG)))) + ); + + } @Test public void testProgrammingLanguageSearch() throws Exception { final SearchInputMetadataDTO searchMetadata =