Skip to content

Commit

Permalink
Merge pull request #122 from CSCfi/devel
Browse files Browse the repository at this point in the history
Publication author name search improvement. OpenShift template update.
  • Loading branch information
sarkikos authored Mar 22, 2024
2 parents b15129c + 422b535 commit 3c4709c
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 118 deletions.
47 changes: 47 additions & 0 deletions aspnetcore/openshift/indexer/template-indexer-app-devel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is part of the research.fi api
#
# Copyright 2024 Ministry of Education and Culture, Finland
#
# :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
# :license: MIT
apiVersion: v1
kind: Template
metadata:
labels:
app: publicapi-indexer-devel
template: publicapi-indexer-devel
name: publicapi-indexer-devel
objects:
# ImageStream (development)
- apiVersion: v1
kind: ImageStream
metadata:
name: publicapi-indexer-devel
labels:
app: publicapi-indexer-devel
spec:
lookupPolicy:
local: true

# BuildConfig using Docker build strategy
- apiVersion: v1
kind: BuildConfig
metadata:
name: publicapi-indexer-build-devel
labels:
app: publicapi-indexer-devel
spec:
source:
git:
uri: https://github.com/CSCfi/research-fi-publicapi.git
ref: devel
contextDir: .
strategy:
dockerStrategy:
dockerfilePath: aspnetcore/openshift/indexer/Dockerfile
output:
to:
kind: ImageStreamTag
name: publicapi-indexer-devel:latest
successfulBuildsHistoryLimit: 4
failedBuildsHistoryLimit: 4
47 changes: 47 additions & 0 deletions aspnetcore/openshift/indexer/template-indexer-app-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is part of the research.fi api
#
# Copyright 2024 Ministry of Education and Culture, Finland
#
# :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
# :license: MIT
apiVersion: v1
kind: Template
metadata:
labels:
app: publicapi-indexer-production
template: publicapi-indexer-production
name: publicapi-indexer-production
objects:
# ImageStream (production)
- apiVersion: v1
kind: ImageStream
metadata:
name: publicapi-indexer-production
labels:
app: publicapi-indexer-production
spec:
lookupPolicy:
local: true

# BuildConfig using Docker build strategy
- apiVersion: v1
kind: BuildConfig
metadata:
name: publicapi-indexer-build-production
labels:
app: publicapi-indexer-production
spec:
source:
git:
uri: https://github.com/CSCfi/research-fi-publicapi.git
ref: main
contextDir: .
strategy:
dockerStrategy:
dockerfilePath: aspnetcore/openshift/indexer/Dockerfile
output:
to:
kind: ImageStreamTag
name: publicapi-indexer-production:latest
successfulBuildsHistoryLimit: 4
failedBuildsHistoryLimit: 4
47 changes: 47 additions & 0 deletions aspnetcore/openshift/indexer/template-indexer-app-qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is part of the research.fi api
#
# Copyright 2024 Ministry of Education and Culture, Finland
#
# :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
# :license: MIT
apiVersion: v1
kind: Template
metadata:
labels:
app: publicapi-indexer-qa
template: publicapi-indexer-qa
name: publicapi-indexer-qa
objects:
# ImageStream (qa)
- apiVersion: v1
kind: ImageStream
metadata:
name: publicapi-indexer-qa
labels:
app: publicapi-indexer-qa
spec:
lookupPolicy:
local: true

# BuildConfig using Docker build strategy
- apiVersion: v1
kind: BuildConfig
metadata:
name: publicapi-indexer-build-qa
labels:
app: publicapi-indexer-qa
spec:
source:
git:
uri: https://github.com/CSCfi/research-fi-publicapi.git
ref: qa
contextDir: .
strategy:
dockerStrategy:
dockerfilePath: aspnetcore/openshift/indexer/Dockerfile
output:
to:
kind: ImageStreamTag
name: publicapi-indexer-qa:latest
successfulBuildsHistoryLimit: 4
failedBuildsHistoryLimit: 4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of the research.fi api
#
# Copyright 2022 Ministry of Education and Culture, Finland
# Copyright 2024 Ministry of Education and Culture, Finland
#
# :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
# :license: MIT
Expand All @@ -9,8 +9,8 @@ kind: Template
metadata:
labels:
app: publicapi-indexer-devel
template: publicapi-indexer-devel
name: publicapi-indexer-devel
template: publicapi-indexer-cronjob-devel
name: publicapi-indexer-cronjob-devel
objects:
# Recurring CronJob (devel)
# Indexes db entities to ElasticSearch.
Expand Down Expand Up @@ -116,36 +116,3 @@ objects:
name: publicapi-api-config-devel
key: "QueryTimeout"
restartPolicy: Never
# ImageStream (development)
- apiVersion: v1
kind: ImageStream
metadata:
name: publicapi-indexer-devel
labels:
app: publicapi-indexer-devel
spec:
lookupPolicy:
local: true

# BuildConfig using Docker build strategy
- apiVersion: v1
kind: BuildConfig
metadata:
name: publicapi-indexer-build-devel
labels:
app: publicapi-indexer-devel
spec:
source:
git:
uri: https://github.com/CSCfi/research-fi-publicapi.git
ref: devel
contextDir: .
strategy:
dockerStrategy:
dockerfilePath: aspnetcore/openshift/indexer/Dockerfile
output:
to:
kind: ImageStreamTag
name: publicapi-indexer-devel:latest
successfulBuildsHistoryLimit: 4
failedBuildsHistoryLimit: 4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of the research.fi api
#
# Copyright 2023 Ministry of Education and Culture, Finland
# Copyright 2024 Ministry of Education and Culture, Finland
#
# :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
# :license: MIT
Expand All @@ -9,8 +9,8 @@ kind: Template
metadata:
labels:
app: publicapi-indexer-production
template: publicapi-indexer-production
name: publicapi-indexer-production
template: publicapi-indexer-cronjob-production
name: publicapi-indexer-cronjob-production
objects:
# Recurring CronJob (production)
# Indexes db entities to ElasticSearch.
Expand Down Expand Up @@ -116,36 +116,3 @@ objects:
name: publicapi-api-config-production
key: "QueryTimeout"
restartPolicy: Never
# ImageStream (production)
- apiVersion: v1
kind: ImageStream
metadata:
name: publicapi-indexer-production
labels:
app: publicapi-indexer-production
spec:
lookupPolicy:
local: true

# BuildConfig using Docker build strategy
- apiVersion: v1
kind: BuildConfig
metadata:
name: publicapi-indexer-build-production
labels:
app: publicapi-indexer-production
spec:
source:
git:
uri: https://github.com/CSCfi/research-fi-publicapi.git
ref: main
contextDir: .
strategy:
dockerStrategy:
dockerfilePath: aspnetcore/openshift/indexer/Dockerfile
output:
to:
kind: ImageStreamTag
name: publicapi-indexer-production:latest
successfulBuildsHistoryLimit: 4
failedBuildsHistoryLimit: 4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of the research.fi api
#
# Copyright 2023 Ministry of Education and Culture, Finland
# Copyright 2024 Ministry of Education and Culture, Finland
#
# :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
# :license: MIT
Expand All @@ -9,8 +9,8 @@ kind: Template
metadata:
labels:
app: publicapi-indexer-qa
template: publicapi-indexer-qa
name: publicapi-indexer-qa
template: publicapi-indexer-cronjob-qa
name: publicapi-indexer-cronjob-qa
objects:
# Recurring CronJob (qa)
# Indexes db entities to ElasticSearch.
Expand Down Expand Up @@ -115,37 +115,4 @@ objects:
configMapKeyRef:
name: publicapi-api-config-qa
key: "QueryTimeout"
restartPolicy: Never
# ImageStream (qa)
- apiVersion: v1
kind: ImageStream
metadata:
name: publicapi-indexer-qa
labels:
app: publicapi-indexer-qa
spec:
lookupPolicy:
local: true

# BuildConfig using Docker build strategy
- apiVersion: v1
kind: BuildConfig
metadata:
name: publicapi-indexer-build-qa
labels:
app: publicapi-indexer-qa
spec:
source:
git:
uri: https://github.com/CSCfi/research-fi-publicapi.git
ref: qa
contextDir: .
strategy:
dockerStrategy:
dockerfilePath: aspnetcore/openshift/indexer/Dockerfile
output:
to:
kind: ImageStreamTag
name: publicapi-indexer-qa:latest
successfulBuildsHistoryLimit: 4
failedBuildsHistoryLimit: 4
restartPolicy: Never
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,45 @@ private static IEnumerable<Func<QueryContainerDescriptor<Publication>, QueryCont
.Query(parameters.AuthorsText)));
}

if (!string.IsNullOrWhiteSpace(parameters.AuthorFirstNames))
if (!string.IsNullOrWhiteSpace(parameters.AuthorFirstNames) && string.IsNullOrWhiteSpace(parameters.AuthorLastName))
{
subQueries.Add(t =>
t.Match(query => query.Field(f => f.Authors.Suffix(nameof(Author.FirstNames)))
.Query(parameters.AuthorFirstNames)));
// Only first names
subQueries.Add(
q => q.Nested(
query => query
.Path(p => p.Authors)
.Query(
q => q.Match(m => m
.Field(f => f.Authors.Suffix(nameof(Author.FirstNames)))
.Query(parameters.AuthorFirstNames)))));
}

if (!string.IsNullOrWhiteSpace(parameters.AuthorLastName))
else if (string.IsNullOrWhiteSpace(parameters.AuthorFirstNames) && !string.IsNullOrWhiteSpace(parameters.AuthorLastName))
{
subQueries.Add(t =>
t.Match(query => query.Field(f => f.Authors.Suffix(nameof(Author.LastName)))
.Query(parameters.AuthorLastName)));
// Only last name
subQueries.Add(
q => q.Nested(
query => query
.Path(p => p.Authors)
.Query(
q => q.Match(m => m
.Field(f => f.Authors.Suffix(nameof(Author.LastName)))
.Query(parameters.AuthorLastName)))));
}
else if (!string.IsNullOrWhiteSpace(parameters.AuthorFirstNames) && !string.IsNullOrWhiteSpace(parameters.AuthorLastName))
{
// Both first names and last name
subQueries.Add(
q => q.Nested(
query => query
.Path(p => p.Authors)
.Query(
q => q.Bool(b => b
.Must(mu => mu
.Match(m => m
.Field(f => f.Authors.Suffix(nameof(Author.FirstNames))).Query(parameters.AuthorFirstNames)
), mu => mu
.Match(m => m
.Field(f => f.Authors.Suffix(nameof(Author.LastName))).Query(parameters.AuthorLastName)))))));
}

if (!string.IsNullOrWhiteSpace(parameters.ConferenceName))
Expand Down
1 change: 1 addition & 0 deletions aspnetcore/src/Service.Models/Publication/Publication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Publication
/// <summary>
/// Tekijät
/// </summary>
[Nested]
public List<Author>? Authors { get; set; }

/// <summary>
Expand Down

0 comments on commit 3c4709c

Please sign in to comment.