Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSCTTV-3770 publication author name search improvement #121

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
/// <summary>
/// Tekijät
/// </summary>
[Nested]
public List<Author>? Authors { get; set; }

/// <summary>
Expand Down Expand Up @@ -161,12 +162,12 @@
/// <summary>
/// Avoin saatavuus
/// </summary>
public ReferenceData OpenAccess { get; set; }

Check warning on line 165 in aspnetcore/src/Service.Models/Publication/Publication.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'OpenAccess' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 165 in aspnetcore/src/Service.Models/Publication/Publication.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'OpenAccess' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

/// <summary>
/// Julkaisukanavan avoin saatavuus
/// </summary>
public ReferenceData PublisherOpenAccess { get; set; }

Check warning on line 170 in aspnetcore/src/Service.Models/Publication/Publication.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'PublisherOpenAccess' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 170 in aspnetcore/src/Service.Models/Publication/Publication.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'PublisherOpenAccess' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

/// <summary>
/// Tieteenalat
Expand Down
Loading