solraium faceted search
This commit is contained in:
parent
024002eded
commit
9855c235b7
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Frontend;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\View\View;
|
|
||||||
use Illuminate\Support\Facades\Input;
|
use Illuminate\Support\Facades\Input;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class SolariumController extends Controller
|
class SolariumController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -21,15 +21,42 @@ class SolariumController extends Controller
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): View
|
public function index(Request $request): View
|
||||||
{
|
{
|
||||||
if (Input::has('q')) {
|
if (Input::has('q') && Input::get('q') != "") {
|
||||||
// Create a search query
|
// Create a search query
|
||||||
$query = $this->client->createSelect();
|
$query = $this->client->createSelect();
|
||||||
|
|
||||||
// Set the query string
|
// if (Input::get('q') != "") {
|
||||||
if (Input::get('q') != "") {
|
// // $query->setQuery(Input::get('q'));
|
||||||
|
// //better use placeholder to escape the search phrase:
|
||||||
|
// $query->setQuery('%P1%', array(Input::get('q')));
|
||||||
|
// } else {
|
||||||
|
// $query = $this->client->createQuery($this->client::QUERY_SELECT);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//Set the query string
|
||||||
|
//$query->setQuery(Input::get('q'));
|
||||||
$query->setQuery('%P1%', array(Input::get('q')));
|
$query->setQuery('%P1%', array(Input::get('q')));
|
||||||
} else {
|
|
||||||
$query = $this->client->createQuery($this->client::QUERY_SELECT);
|
|
||||||
|
// Create a DisMax query
|
||||||
|
$dismax = $query->getDisMax();
|
||||||
|
// Set the fields to query, and their relative weights
|
||||||
|
$dismax->setQueryFields('title^3 abstract^2 subject^1');
|
||||||
|
|
||||||
|
$facetSet = $query->getFacetSet();
|
||||||
|
$facetSet->createFacetField('year')->setField('year');
|
||||||
|
$facetSet->createFacetField('language')->setField('language');
|
||||||
|
$facetSet->createFacetField('datatype')->setField('doctype');
|
||||||
|
|
||||||
|
|
||||||
|
if (Input::has('year')) {
|
||||||
|
$query->createFilterQuery('year')->setQuery(sprintf('year:%s', Input::get('year')));
|
||||||
|
}
|
||||||
|
if (Input::has('language')) {
|
||||||
|
$query->createFilterQuery('language')->setQuery(sprintf('language:%s', Input::get('language')));
|
||||||
|
}
|
||||||
|
if (Input::has('datatype')) {
|
||||||
|
$query->createFilterQuery('datatype')->setQuery(sprintf('doctype:%s', Input::get('datatype')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the query and return the result
|
// Execute the query and return the result
|
||||||
|
@ -41,6 +68,7 @@ class SolariumController extends Controller
|
||||||
'resultset' => $resultset,
|
'resultset' => $resultset,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
// No query to execute, just return the search form.
|
||||||
return view('frontend.search.index');
|
return view('frontend.search.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +94,7 @@ class SolariumController extends Controller
|
||||||
$query = $this->client->createSelect();
|
$query = $this->client->createSelect();
|
||||||
|
|
||||||
// $query = $this->client->createSelect();
|
// $query = $this->client->createSelect();
|
||||||
$query->setQuery('title:'. $filter);
|
$query->setQuery('title:' . $filter);
|
||||||
// set a query (all prices starting from 12)
|
// set a query (all prices starting from 12)
|
||||||
// $query->setQuery('price:[12 TO *]');
|
// $query->setQuery('price:[12 TO *]');
|
||||||
// set start and rows param (comparable to SQL limit) using fluent interface
|
// set start and rows param (comparable to SQL limit) using fluent interface
|
||||||
|
|
|
@ -4,7 +4,6 @@ use Carbon\Carbon;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
|
||||||
class MimetypeTableSeeder extends Seeder
|
class MimetypeTableSeeder extends Seeder
|
||||||
{
|
{
|
||||||
public function run()
|
public function run()
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
<h3 class="separator">SEARCH</h3>
|
<h3 class="separator">SEARCH</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<!-- SEARCH RESULTS GO HERE, EXACTLY AS BEFORE -->
|
||||||
|
|
||||||
<div class="twelve columns">
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="sidebar-simplesearch">
|
<div class="sidebar-simplesearch">
|
||||||
{{ Form::open(array('method' => 'GET')) }}
|
{{ Form::open(array('method' => 'GET')) }}
|
||||||
|
@ -31,18 +29,77 @@
|
||||||
{{ Form::close() }}
|
{{ Form::close() }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if (isset($resultset))
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="four columns">
|
||||||
|
<div id="left-bar">
|
||||||
|
<h3 class="indexheader">Refine by</h3>
|
||||||
|
<?php $facet = $resultset->getFacetSet()->getFacet('language'); ?>
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
|
||||||
|
{{-- <h3 class="panel-title">Language</h3> --}}
|
||||||
|
<h3 class="filterViewModelName">Language</h3>
|
||||||
|
|
||||||
|
<ul class="filterItems">
|
||||||
|
@foreach ($facet as $value => $count)
|
||||||
|
@if ($count)
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a class="firstLabel"
|
||||||
|
href="?{{ http_build_query(array_merge(Input::all(), array('language' => $value))) }}">{{ $value }}</a>
|
||||||
|
<span class="badge">{{ $count }}</span>
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php $facet = $resultset->getFacetSet()->getFacet('datatype'); ?>
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
{{-- <h3 class="panel-title">Datatype</h3> --}}
|
||||||
|
<h3 class="filterViewModelName">Data Type</h3>
|
||||||
|
<ul class="filterItems">
|
||||||
|
@foreach ($facet as $value => $count)
|
||||||
|
@if ($count)
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a class="firstLabel"
|
||||||
|
href="?{{ http_build_query(array_merge(Input::all(), array('datatype' => $value))) }}">{{ $value }}</a>
|
||||||
|
<span class="badge">{{ $count }}</span>
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php $facet = $resultset->getFacetSet()->getFacet('year'); ?>
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<h3 class="filterViewModelName">Year</h3>
|
||||||
|
|
||||||
|
<ul class="filterItems">
|
||||||
|
@foreach ($facet as $value => $count)
|
||||||
|
@if ($count)
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a class="firstLabel"
|
||||||
|
href="?{{ http_build_query(array_merge(Input::all(), array('year' => $value))) }}">{{ $value }}</a>
|
||||||
|
<span class="badge">{{ $count }}</span>
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="eight columns">
|
||||||
@if (isset($resultset))
|
@if (isset($resultset))
|
||||||
<header>
|
<header>
|
||||||
<p>Your search yielded <strong>{{ $resultset->getNumFound() }}</strong> results:</p>
|
<p>Your search yielded <strong>{{ $resultset->getNumFound() }}</strong> results:</p>
|
||||||
<hr />
|
<hr />
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="row">
|
<section class="results normal">
|
||||||
<ul class="search-items isotope js-isotope u-cf">
|
<ul class="search-items isotope js-isotope u-cf">
|
||||||
|
|
||||||
@foreach ($resultset as $document)
|
@foreach ($resultset as $document)
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
|
@ -57,17 +114,24 @@
|
||||||
<div class="blog-meta">
|
<div class="blog-meta">
|
||||||
{{ date('D, m M, Y', $document->server_date_modified) }}
|
{{ date('D, m M, Y', $document->server_date_modified) }}
|
||||||
</div>
|
</div>
|
||||||
|
@if (isset($document->title_additional) && is_array($document->title_additional))
|
||||||
|
<div class="blog-meta">
|
||||||
|
<em>Additional Title: {{ implode('; ', $document->title_additional) }}</em>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="post-description">
|
<div class="post-description">
|
||||||
|
|
||||||
@if (is_array($document->author))
|
@if (is_array($document->author))
|
||||||
<em>Author: {{ implode(', ', $document->author) }}</em>
|
<em>Author: {{ implode('; ', $document->author) }}</em>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<em>Abstract: {{ $document->abstract_output }}</em>
|
<em>Abstract: {{ $document->abstract_output }}</em>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<em>Creating Corporation: {{ $document->creating_corporation }}</em>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,10 +140,12 @@
|
||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
|
</section>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -89,6 +155,132 @@
|
||||||
@section('head')
|
@section('head')
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
*-------------------------------------------------- */
|
||||||
|
|
||||||
|
/* lists in the left bar */
|
||||||
|
/*-------------------------------------------------- */
|
||||||
|
.overflowing {
|
||||||
|
color: #444444;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overflowing span {
|
||||||
|
color: #444444;
|
||||||
|
font-style: italic;
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.filterItems li {
|
||||||
|
min-height: 15px;
|
||||||
|
color: #444;
|
||||||
|
font-size: 12px;
|
||||||
|
|
||||||
|
list-style-type: disc;
|
||||||
|
/*list-style-position:inside;*/
|
||||||
|
/*
|
||||||
|
* We want the bullets outside of the list,
|
||||||
|
* so the text is aligned. Now the actual bullet
|
||||||
|
* is outside of the list’s container
|
||||||
|
*/
|
||||||
|
list-style-position: outside;
|
||||||
|
/*
|
||||||
|
* Because the bullet is outside of the list’s
|
||||||
|
* container, indent the list entirely
|
||||||
|
*/
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filterItems.limited li:nth-of-type(1n+6) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.filterItems .active {
|
||||||
|
background-color: lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*ul.filterItems li.hover{
|
||||||
|
background-color: yellow;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*ul.filterItems li.hover .firstLabel,
|
||||||
|
ul.filterItems li.hover a{
|
||||||
|
color: #0099cc;
|
||||||
|
cursor:pointer;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*ul.filterItems span.hover {
|
||||||
|
color: #0099cc;
|
||||||
|
cursor:pointer;
|
||||||
|
}*/
|
||||||
|
ul.filterItems li a:hover {
|
||||||
|
color: #0099cc;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Relativer Tooltip */
|
||||||
|
.tooltip {
|
||||||
|
position: relative;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bolder;
|
||||||
|
color: #444444;
|
||||||
|
cursor: pointer;
|
||||||
|
overflow: visible;
|
||||||
|
font-size: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.sidebar.left {
|
||||||
|
background-color: rgb(244, 244, 244);
|
||||||
|
float: left;
|
||||||
|
border-left: none;
|
||||||
|
width: 250px;
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #left-bar {
|
||||||
|
position:absolute;
|
||||||
|
height:auto;
|
||||||
|
width:auto;
|
||||||
|
bottom:0;
|
||||||
|
top:0;
|
||||||
|
left:0;
|
||||||
|
right:0;
|
||||||
|
margin: 15px;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.sidebar.right {
|
||||||
|
border: none;
|
||||||
|
margin-left: 250px;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#left-bar .indexheader {
|
||||||
|
color: #a9a9a9;
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#left-bar .filterViewModelName {
|
||||||
|
color: black;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
|
||||||
|
/* font-size: 12px; */
|
||||||
|
display: block;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.sidebar-simplesearch {
|
.sidebar-simplesearch {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-bottom: 2.5em;
|
margin-bottom: 2.5em;
|
||||||
|
@ -111,4 +303,3 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user