From f7ceb6081f783d383b3273fc8b3dab5a517eefc6 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sun, 2 Jun 2019 07:27:15 +0200 Subject: [PATCH] support sparse fieldsets --- app/controllers/dois_controller.rb | 12 +++++++++++- docker-compose.yml | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 9307788b8..08eb6691b 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -190,7 +190,17 @@ def index } bmr = Benchmark.ms { - render json: DoiSerializer.new(results, options).serialized_json, status: :ok + logger.info params[:fields] + # support sparse fieldsets + if params[:fields] + f = params.to_unsafe_h.dig(:fields) + f = { dois: "doi" } unless f.is_a?(Hash) + f.each { |k, v| f[k] = v.split(",") } + + render json: DoiSerializer.new(results, options.merge(fields: f)).serialized_json, status: :ok + else + render json: DoiSerializer.new(results, options).serialized_json, status: :ok + end } if bmr > 3000 diff --git a/docker-compose.yml b/docker-compose.yml index 1f0a67b8e..ef9884995 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: - "9301:9300" environment: discovery.type: single-node - ES_JAVA_OPTS: -Xms1g -Xmx1g + ES_JAVA_OPTS: -Xms512m -Xmx512m ELASTIC_PASSWORD: changeme xpack.security.enabled: "false" http.cors.enabled: "true"