diff --git a/app/assets/stylesheets/objects/_search-result.scss b/app/assets/stylesheets/objects/_search-result.scss index ff97374..715958d 100644 --- a/app/assets/stylesheets/objects/_search-result.scss +++ b/app/assets/stylesheets/objects/_search-result.scss @@ -12,6 +12,6 @@ margin-bottom: 0.1rem; } -.search-result .metainfo { - font-size: 0.8rem; +.search-result .current { + font-weight: $font-weight-bold; } diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index fefbf16..8653b7c 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -24,6 +24,24 @@ class SearchController < ApplicationController def execute_search @response = Paper.search(@search_definition.to_definition) @papers = @response.page(params[:page]).results + @sub = Hash.new + @papers.each do |paper| + @sub_search_definition = Elasticsearch::DSL::Search.search do + query do + query_string do + query "*" + (paper.reference.start_with?("VI-") ? paper.reference.split("-")[2] : paper.reference.split("-")[1]) + "*" + fields ["reference"] + end + end + + sort do + by :published_at, order: 'asc' + by :reference, order: 'asc' + end + end + @sub_papers = Paper.search(@sub_search_definition) + @sub[paper.reference] = @sub_papers + end @paper_type_facets = extract_facets('paper_types') @originator_facets = extract_facets('originators') end diff --git a/app/models/paper.rb b/app/models/paper.rb index 77ab1d3..e36b744 100644 --- a/app/models/paper.rb +++ b/app/models/paper.rb @@ -26,6 +26,7 @@ class Paper < ActiveRecord::Base indexes :name, type: :string, analyzer: "german" indexes :content, type: :string, analyzer: "german" indexes :resolution, type: :string, analyzer: "german" + indexes :reference, type: :string, index: :not_analyzed indexes :paper_type, type: :string, index: :not_analyzed indexes :published_at, type: :date, index: :not_analyzed indexes :originator, type: :string, index: :not_analyzed diff --git a/app/views/search/index.html.slim b/app/views/search/index.html.slim index 42bb61d..ac1d78d 100644 --- a/app/views/search/index.html.slim +++ b/app/views/search/index.html.slim @@ -5,8 +5,6 @@ div - if params[:q].present? .left | #{@papers.total} Treffer - .right - / button.button. TODO: Suche Abbonieren - else | #{pluralize(@papers.total, "Dokument", "Dokumente")} in der Datenbank div @@ -14,14 +12,12 @@ div - @papers.each do |doc| li.search-result article - h4 = link_to doc.name, doc.url, target: '_blank' - div.metainfo - span.paper_type = doc.paper_type - ' - span.originator = doc.originator - ' - span.published = l doc.published_at.to_date - /! score: #{doc._score} + h4 = doc.name + ul + - @sub[doc.reference].each do |sub| + li class="#{'current' if sub.reference == doc.reference}" + div = link_to "#{l sub.published_at.to_date}: #{sub.paper_type} von #{sub.originator.join(", ")}", sub.url, target: '_blank' + div#pagination = paginate @papers