test for keywords db performance

This commit is contained in:
2017-01-07 09:10:42 +01:00
parent c283568757
commit 4f77515bbd
20 changed files with 1211 additions and 63 deletions

View File

@@ -18,6 +18,7 @@ import org.lucares.recommind.logs.Plotter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -62,7 +63,7 @@ public class PdbController implements HardcodedValues, CollectionUtils {
@RequestMapping(path = "/autocomplete", //
method = RequestMethod.GET, //
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, //
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, // APPLICATION_FORM_URLENCODED_VALUE
produces = MediaType.APPLICATION_JSON_UTF8_VALUE //
)
@ResponseBody
@@ -94,11 +95,30 @@ public class PdbController implements HardcodedValues, CollectionUtils {
produces = MediaType.APPLICATION_JSON_UTF8_VALUE //
)
@ResponseBody
List<String> fields() {
List<String> fields(@RequestParam(name = "query") final String query) {
try {
final List<String> fields = db.getDb().getFields(query);
final List<String> fields = db.getDb().getFields();
return fields;
} catch (final Exception e) {
e.printStackTrace();
throw new InternalServerError(e);
}
}
@RequestMapping(path = "/fields/{fieldName}/values", //
method = RequestMethod.GET, //
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, //
produces = MediaType.APPLICATION_JSON_UTF8_VALUE //
)
@ResponseBody
List<String> fields(@PathVariable(name = "fieldName") final String fieldName,
@RequestParam(name = "query") final String query) {
try {
final List<String> fields = db.getDb().getFieldsValues(query, fieldName);
return fields;

View File

@@ -33,35 +33,30 @@ html, body {
#search-bar {
background-color: #aaa;
text-align: right;
padding-bottom:3px;
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
#search-bar #search-query {
width:100%;
padding:2;
border:0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
#filter-bar {
}
#search-input-wrapper {
text-align: left;
display: flex;
padding: 5px;
}
#search-input-wrapper .autocomplete {
overflow-y: scroll;
background: white;
#add-filter {
float:right;
}
#search-bar #search-submit {
.template-filter-values {
}
#button-bar {
text-align: right;
}
#button-bar #search-submit {
margin-right:3px;
}
@@ -82,6 +77,7 @@ html, body {
line-height: 1.2em;
}
.center
{
display: flex;

View File

@@ -3,12 +3,11 @@
<head>
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="js/search.js"></script>
<script type="text/javascript" src="js/autocomplete.js"></script>
<script type="text/javascript" src="js/mustache.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/typography.css">
<link rel="stylesheet" type="text/css" href="css/design.css">
<link rel="stylesheet" type="text/css" href="css/icons.css">
<link rel="stylesheet" type="text/css" href="css/loading.css">
<link rel="stylesheet" type="text/css" href="css/autocomplete.min.css">
</head>
<body>
<div id="content">
@@ -16,16 +15,29 @@
<div id="logo">LOGO</div>
</div>
<div id="search-bar">
<div id="search-input-wrapper">
<input id="search-input" data-autocomplete="autocomplete"
data-autocomplete-empty-message="nothing found" />
<div id="filter-bar">
<button id="add-filter">add</button>
</div>
<div id="search-group-by">
<div id="button-bar">
<button id="search-submit"><i class="fa fa-search"> Search</i></button>
</div>
<button id="search-submit"><i class="fa fa-search"> Search</i></button>
</div>
<div id="result-view">
</div>
</div>
<div style="display:none">
<div id="template-filter">
<div class="filter">
<select class="template-filter-field" name="filter-field" id="filter-field">
{{#fields}}
<option name="{{name}}">{{name}}</option>
{{/fields}}
</select>
<select class="template-filter-values" name="filter-values" id="filter-values" multiple="multiple">
</select>
</div>
</div>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@@ -3,48 +3,97 @@ $(document).ready(function(){
$('#search-submit').click(plot);
initGroupBy();
initFilter();
AutoComplete({
HttpMethod: "GET",
Delay: 300,
_QueryArg: function() {
var caretIndex = document.getElementById('search-input').selectionStart;
return 'caretIndex=' + caretIndex + '&query';
},
_Post: function(response) {
var result = [];
var responseObject = JSON.parse(response);
responseObject['proposals'].forEach(function(item, index){
var proposal = {};
proposal['Label'] = item.value;
proposal['Value'] = item.proposedQuery;
result.push(proposal);
});
console.log(JSON.stringify(result));
return result;
}
});
});
function initGroupBy()
{
var successCallback = function (response) {
function initFilter() {
response.forEach(function(item, index){
$('#search-group-by').append('<input type="radio" id="groupBy-'+index+'" name="groupBy" value="'+item+'" /><label for="groupBy-'+index+'">'+item+'</label>');
var successCallback = function (fields) {
var fieldsView = [{name: ""}];
fields.forEach(function(item, index){
fieldsView.push( {name: item} );
});
var template = $('#template-filter').html();
var view = {
fields: fieldsView
};
var rendered = Mustache.render(template, view);
$('#filter-bar').append(rendered);
$('#filter-values').hide();
$('#filter-field').change(function() {
if ($(this).val() == ""){
$('#filter-values').hide();
}else{
addFieldValues($(this).val());
}
});
$('#add-filter').click(function(){
var field = $('#filter-field').val();
var values = $('#filter-values').val();
if (field != ""
&& values != [] )
{
var query = "";
values.forEach(function (value, index) {
if (query.length > 0)
{
query += ",";
}
query += field+"="+value;
} );
$('#filter-bar').append(query);
}
});
};
getFields( successCallback);
}
function addFieldValues(field){
var params = {};
params['query'] = "";
var successCallback = function (values){
$('#result-view').text("SUCCESS: " + JSON.stringify(values));
values.forEach(function (item, index){
$('#filter-values').append($('<option>', {
value: item,
text : item
}));
});
$('#filter-values').show();
};
var errorCallback = function (){
$('#result-view').text("FAILED: " + JSON.stringify(e));
};
getJson("fields/"+field+"/values", params, successCallback);
}
function getFields( successCallback) {
var errorCallback = function (){
$('#result-view').text("FAILED: " + JSON.stringify(e));
};
getJson("fields", {}, successCallback, errorCallback)
var params = {};
params['query'] = "";
getJson("fields", params, successCallback, errorCallback)
}
function showLoadingIcon()