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

[SPIKE] Adding aggregations #780

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions app/graphql/types/aggregations_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AggregationsType < Types::BaseObject
field :languages, [Types::AggregationCountType], null: true, description: 'Total search results by language'
field :literary_form, [Types::AggregationCountType], null: true,
description: 'Total search results by fiction or nonfiction'
field :publication_information, [Types::AggregationCountType], null: true, description: 'Total search results by publisher'
field :source, [Types::AggregationCountType], null: true,
description: 'Total search results by source record system'
field :subjects, [Types::AggregationCountType], null: true, description: 'Total search results by subject term'
Expand Down
4 changes: 4 additions & 0 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def record_id(id:, index:)
'aggregation for a list of possible values'
argument :literary_form_filter, String, required: false, default_value: nil,
description: 'Filter results by fiction or nonfiction'
argument :publication_information_filter, [String], required: false, default_value: nil,
description: 'Filter results by publication information'
argument :source_filter, [String], required: false, default_value: nil,
description: 'Filter by source record system. Use the `sources` aggregation ' \
'for a list of possible values'
Expand Down Expand Up @@ -129,6 +131,7 @@ def construct_query(searchterm, citation, contributors, funding_information, geo
query[:contributors_filter] = filters[:contributors_filter]
query[:languages_filter] = filters[:languages_filter]
query[:literary_form_filter] = filters[:literary_form_filter]
query[:publication_information_filter] = filters[:publication_information_filter]
query = source_deprecation_handler(query, filters[:source_filter], source)
query[:subjects_filter] = filters[:subjects_filter]
query
Expand All @@ -149,6 +152,7 @@ def collapse_buckets(es_aggs)
subjects: es_aggs['subjects']['subject_names']['buckets'],
languages: es_aggs['languages']['buckets'],
literary_form: es_aggs['literary_form']['buckets'],
publication_information: es_aggs['publication_information']['buckets'],
format: es_aggs['content_format']['buckets'],
content_type: es_aggs['content_type']['buckets']
}
Expand Down
5 changes: 5 additions & 0 deletions app/models/opensearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ def aggregations
field: 'literary_form'
}
},
publication_information: {
terms: {
field: 'publication_information'
}
},
source: {
terms: {
field: 'source'
Expand Down
Loading