Query ES, show results

This commit is contained in:
Andreas Haller 2014-11-19 21:54:36 +01:00
parent 7cd9f207f5
commit 2abba45f4c
8 changed files with 44 additions and 12 deletions

View file

@ -14,12 +14,10 @@ gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes # See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby # gem 'therubyracer', platforms: :ruby
gem 'slim-rails' gem 'slim-rails'
# Use jquery as the JavaScript library # Use jquery as the JavaScript library
gem 'jquery-rails' gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks' gem 'turbolinks'
# Assets # Assets
gem 'foundation-rails' gem 'foundation-rails'
@ -27,6 +25,8 @@ gem 'foundation-rails'
gem 'omniauth' gem 'omniauth'
gem 'omniauth-browserid' gem 'omniauth-browserid'
gem 'elasticsearch'
# bundle exec rake doc:rails generates the API under doc/api. # bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc gem 'sdoc', '~> 0.4.0', group: :doc

View file

@ -44,6 +44,14 @@ GEM
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.8.0) coffee-script-source (1.8.0)
elasticsearch (1.0.6)
elasticsearch-api (= 1.0.6)
elasticsearch-transport (= 1.0.6)
elasticsearch-api (1.0.6)
multi_json
elasticsearch-transport (1.0.6)
faraday
multi_json
erubis (2.7.0) erubis (2.7.0)
execjs (2.2.2) execjs (2.2.2)
faraday (0.9.0) faraday (0.9.0)
@ -151,6 +159,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
capybara capybara
coffee-rails (~> 4.0.0) coffee-rails (~> 4.0.0)
elasticsearch
foundation-rails foundation-rails
jquery-rails jquery-rails
launchy launchy

View file

@ -10,8 +10,10 @@
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope. * file per style scope.
* *
*= require_tree .
*= require_self *= require_self
*= require foundation_and_overrides
*/ */
@import 'foundation_and_overrides';
@import 'objects/search-result';

View file

@ -0,0 +1,3 @@
.search-result {
border-bottom: 1px solid $table-border-color;
}

View file

@ -1,3 +0,0 @@
// Place all the styles related to the sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -1,4 +1,8 @@
class SearchController < ApplicationController class SearchController < ApplicationController
def index def index
@result = if params[:q].present?
es = Elasticsearch::Client.new
es.search index: 'loris', q: params[:q]
end
end end
end end

View file

@ -12,8 +12,8 @@ body
= content_tag :div, msg, class: name = content_tag :div, msg, class: name
.row .row
.large-8.columns .large-8.columns
h2#title h1#title
= link_to 'Willkommen in Leipzig', root_path = link_to 'Stadtratmonitor Leipzig', root_path
.large-4.columns .large-4.columns
ul.inline-list.right ul.inline-list.right
li = render 'login_button' li = render 'login_button'

View file

@ -1,4 +1,21 @@
= form_tag(search_path, method: :get) = form_tag(search_path, method: :get)
= label_tag(:q, 'Suche:') = text_field_tag(:q, params[:q], placeholder: 'Suche…')
= text_field_tag(:q)
= submit_tag 'Suchen', class: 'button' .row
- if @result
.small-9.columns
| #{@result['hits']['total']} Treffer
.small-3.columns
button.button.right TODO: Suche Abbonieren
- if @result
ul.no-bullet
- @result['hits']['hits'].each do |doc|
li.search-result
small = doc['_source']['paperType']
'
small = doc['_source']['originator'].join(', ')
'
small = doc['_source']['publishedDate']
= link_to "https://ratsinfo.leipzig.de/bi/#{doc['_source']['mainFile']}", target: '_blank' do
div = doc['_source']['name']