This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit ad4008fd authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Merge branch '83-search-results-do-not-make-sense2' into 'development'

Resolve "Search results do not make sense"

See merge request sharing/codeability-sharing-platform!16
parents 0df48c11 58b22612
Branches
Tags
2 merge requests!17Initial Merge to Prepare Release 1.0.0,!16Resolve "Search results do not make sense"
Showing
with 53 additions and 42 deletions
......@@ -32,7 +32,6 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;resources&gt;&#13;&#10;&lt;item path=&quot;/gitsearch/target/generated-sources&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;item path=&quot;/gitsearch/target/generated-test-sources&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/resources&gt;}"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/gitsearch/mvnw.cmd}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="generate-sources"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/gitsearch}"/>
</launchConfiguration>
......@@ -33,11 +33,6 @@ local.properties
.loadpath
.factorypath
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
......
......@@ -7,7 +7,7 @@
<buildSpec>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
......
......@@ -5,4 +5,7 @@ encoding//src/main/webapp/i18n/de/global.json=UTF-8
encoding//src/main/webapp/i18n/de/search.json=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding//src/test/resources/at/ac/uibk/gitsearch/repository/search/testData/content1.json=UTF-8
encoding//src/test/resources/at/ac/uibk/gitsearch/repository/search/testData/content2.json=UTF-8
encoding//src/test/resources/at/ac/uibk/gitsearch/repository/search/testData/content3.json=UTF-8
encoding/<project>=UTF-8
......@@ -46,13 +46,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import at.ac.uibk.gitsearch.config.ApplicationProperties;
import at.ac.uibk.gitsearch.service.StatisticsService;
import at.ac.uibk.gitsearch.service.dto.AutoCompleteEntry;
import at.ac.uibk.gitsearch.service.dto.SearchInputDTO;
import at.ac.uibk.gitsearch.service.dto.SearchResultDTO;
import at.ac.uibk.gitsearch.service.dto.SearchResultsDTO;
import at.ac.uibk.gitsearch.service.dto.UserProvidedMetadataDTO.Person;
import at.ac.uibk.gitsearch.service.impl.StatisticsServiceImpl;
@Repository
public class MetaDataRepository {
......@@ -65,13 +63,9 @@ public class MetaDataRepository {
private static final int FRAGMENT_SIZE = 5000;
private final StatisticsService statisticsService;
public MetaDataRepository(RestHighLevelClient elasticsearchClient, ApplicationProperties properties, StatisticsService statisticsService) {
public MetaDataRepository(RestHighLevelClient elasticsearchClient, ApplicationProperties properties) {
this.elasticsearchClient = elasticsearchClient;
this.properties = properties;
this.statisticsService = statisticsService;
}
......@@ -312,37 +306,45 @@ public class MetaDataRepository {
.multiMatchQuery(term, SearchRepositoryConstants.METADATA_DESCRIPTION,
SearchRepositoryConstants.METADATA_KEYWORDS, SearchRepositoryConstants.METADATA_TITLE)
.type(MultiMatchQueryBuilder.Type.PHRASE_PREFIX)));
queryBuilder.must(fullTextBuilder);
if(fullTextBuilder.hasClauses())
queryBuilder.must(fullTextBuilder);
BoolQueryBuilder plBuilder = QueryBuilders.boolQuery();
forEachTerm(searchInputDTO.getMetadata().getProgrammingLanguage(), term -> queryBuilder
forEachTerm(searchInputDTO.getMetadata().getProgrammingLanguage(), term -> plBuilder
.should(QueryBuilders.prefixQuery(SearchRepositoryConstants.METADATA_PROGRAMMING_LANGUAGES, term)));
queryBuilder.must(plBuilder);
if(plBuilder.hasClauses())
queryBuilder.must(plBuilder);
BoolQueryBuilder keywordBuilder = QueryBuilders.boolQuery();
forEachTerm(searchInputDTO.getMetadata().getKeyword(), term -> queryBuilder
forEachTerm(searchInputDTO.getMetadata().getKeyword(), term -> keywordBuilder
.should(QueryBuilders.prefixQuery(SearchRepositoryConstants.METADATA_KEYWORDS, term)));
queryBuilder.must(keywordBuilder);
if(keywordBuilder.hasClauses())
queryBuilder.must(keywordBuilder);
BoolQueryBuilder authorBuilder = QueryBuilders.boolQuery();
if (searchInputDTO.getMetadata().getAuthor() != null)
queryBuilder.should(QueryBuilders
authorBuilder.should(QueryBuilders
.multiMatchQuery(searchInputDTO.getMetadata().getAuthor(),
SearchRepositoryConstants.METADATA_CREATOR, SearchRepositoryConstants.METADATA_CONTRIBUTOR,
SearchRepositoryConstants.METADATA_PUBLISHER)
.type(MultiMatchQueryBuilder.Type.PHRASE_PREFIX));
queryBuilder.must(authorBuilder);
if(authorBuilder.hasClauses())
queryBuilder.must(authorBuilder);
if (searchInputDTO.getMetadata().getTypes()!=null && !searchInputDTO.getMetadata().getTypes().isEmpty()) {
BoolQueryBuilder typeBuilder = QueryBuilders.boolQuery();
searchInputDTO.getMetadata().getTypes().forEach(
type -> typeBuilder.should(QueryBuilders.matchQuery(SearchRepositoryConstants.METADATA_TYPE, type.getExternalName())));
queryBuilder.must(typeBuilder);
if(typeBuilder.hasClauses())
queryBuilder.must(typeBuilder);
}
forEachTerm(searchInputDTO.getMetadata().getLicense(),
term -> queryBuilder.must(QueryBuilders.prefixQuery(SearchRepositoryConstants.METADATA_LICENSE, term)));
// Authorization restrictions
final MatchQueryBuilder publicQuery = QueryBuilders.matchQuery(SearchRepositoryConstants.PROJECT_VISIBILITY, "public")
.fuzzyTranspositions(false).autoGenerateSynonymsPhraseQuery(false);
.fuzzyTranspositions(false).autoGenerateSynonymsPhraseQuery(false).boost(0.0f);
if(user.isEmpty()) {
queryBuilder
.must(publicQuery);
......@@ -351,19 +353,18 @@ public class MetaDataRepository {
// TODO: this is not yet perfect :-( prefix query on namespace is not correct. We need to check for the longest prefix
// better: Make a gitlab api call to all my project I have read access (and that are not public)
final Collection<GrantedAuthority> authorities = user.get().getAuthorities();
final BoolQueryBuilder authQuery = QueryBuilders.boolQuery();
final BoolQueryBuilder authQuery = QueryBuilders.boolQuery().boost(0.0f);
final Stream<QueryBuilder> prefixAuthQueries = authorities.stream()
.filter(auth -> !auth.getAuthority().startsWith("ROLE"))
.filter(auth -> !auth.getAuthority().startsWith("SCOPE"))
.map(auth -> QueryBuilders.prefixQuery(SearchRepositoryConstants.PROJECT_NAMESPACE, auth.getAuthority()));
prefixAuthQueries.forEach(pq -> {authQuery.should(pq);});
queryBuilder.must(QueryBuilders.boolQuery().should(authQuery).should(publicQuery));
if(authQuery.hasClauses())
queryBuilder.must(QueryBuilders.boolQuery().should(authQuery).should(publicQuery));
else
queryBuilder.must(publicQuery);
}
forEachTerm(searchInputDTO.getMetadata().getLicense(),
term -> queryBuilder.must(QueryBuilders.prefixQuery(SearchRepositoryConstants.METADATA_LICENSE, term)));
char[] boundaryChars = { '\n' };
HighlightBuilder highlightBuilder = new HighlightBuilder().highlighterType("plain")
......@@ -391,7 +392,7 @@ public class MetaDataRepository {
float maxScore = searchResponse.getHits().getMaxScore();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
final List<SearchResultDTO> searchResults = new ArrayList<>();
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
......
......@@ -79,7 +79,7 @@ spring:
issuer-uri: https://sharing.codeability-austria.uibk.ac.at
registration:
gitlabOidc:
client-id: ${gitsearch.oauthToken}
client-id: 149276ac11138d9ba72fb3cd12815e3fa2f372866df0eac0f7d1aae5fdffea24
client-secret: 6f480635241f420a361581f4837594ea6f48f5ee6f515c1aa89f325dd922dbb0
server:
......@@ -147,4 +147,4 @@ application:
- "http://localhost:8082/api/sharingPluginConfig"
gitlab:
url: https://sharing.codeability-austria.uibk.ac.at/
generalAccessToken: L8971ypHA-A84Rh6k2GS
\ No newline at end of file
generalAccessToken: zPxPmJE3UXAZJpBzxqej
\ No newline at end of file
@import 'bootstrap4.5.2.min';
@import 'navbar';
.dropdown-item.active, .dropdown-item:active {
background-color: #aaaaaa;
}
......@@ -91,7 +91,7 @@ public class SearchServiceIT {
@Test
public void testProgrammingLanguageSearch() throws Exception {
final SearchInputMetadataDTO searchMetadata = new SearchInputMetadataDTO("JAVA", null, null, null, null);
final SearchInputMetadataDTO searchMetadata = new SearchInputMetadataDTO("Java".toLowerCase(), null, null, null, null);
SearchInputDTO searchQuery = new SearchInputDTO(null, searchMetadata, null, null, null, 0);
SearchResultsDTO searchResultPage = searchService.searchResultPage(searchQuery, 0, SearchInputDTO.PAGE_SIZE);
......
......@@ -33,14 +33,14 @@
"version" : "1.0",
"status" : "final",
"title" : "Meta Test Data 76",
"description" : "Dies sind Teile des Einfhrungskurses an der TU Wien. Momentan hier genutzt zum Testen der Metadateninfrastruktur. Version 1.xxx 3. Zeile",
"description" : "Dies sind Teile des Einführungskurses an der TU Wien. Momentan hier genutzt zum Testen der Metadateninfrastruktur. Version 1.xxx 3. Zeile",
"programmingLanguage" : [
"Java"
],
"language" : [
"de"
],
"educationLevel" : "Anfnger, (to be detailed)",
"educationLevel" : "Anfänger, (to be detailed)",
"audience" : "Anfaenger",
"keyword" : [
"Java",
......
......@@ -33,14 +33,14 @@
"version" : "1.0",
"status" : "final",
"title" : "Meta Test Data 76",
"description" : "Dies sind Teile des Einfhrungskurses an der TU Wien. Momentan hier genutzt zum Testen der Metadateninfrastruktur. Version 1.xxx 3. Zeile",
"description" : "Dies sind Teile des Einführungskurses an der TU Wien. Momentan hier genutzt zum Testen der Metadateninfrastruktur. Version 1.xxx 3. Zeile",
"programmingLanguage" : [
"Java"
],
"language" : [
"de"
],
"educationLevel" : "Anfnger, (to be detailed)",
"educationLevel" : "Anfänger, (to be detailed)",
"audience" : "Anfaenger",
"keyword" : [
"Java",
......
......@@ -33,14 +33,14 @@
"version" : "1.0",
"status" : "final",
"title" : "Meta Test Data 76",
"description" : "Dies sind Teile des Einfhrungskurses an der TU Wien. Momentan hier genutzt zum Testen der Metadateninfrastruktur. Version 1.xxx 3. Zeile",
"description" : "Dies sind Teile des Einführungskurses an der TU Wien. Momentan hier genutzt zum Testen der Metadateninfrastruktur. Version 1.xxx 3. Zeile",
"programmingLanguage" : [
"Java"
],
"language" : [
"de"
],
"educationLevel" : "Anfnger, (to be detailed)",
"educationLevel" : "Anfänger, (to be detailed)",
"audience" : "Anfaenger",
"keyword" : [
"Java",
......
......@@ -12,6 +12,7 @@
},
"mappings" : {
"_doc" : {
"properties" : {
"file" : {
"properties" : {
......@@ -196,5 +197,4 @@
}
}
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment