1

Output search results

This commit is contained in:
Alex Yatskov 2014-07-28 15:51:48 +09:00
parent 54a22051b6
commit a9f03b30f6
2 changed files with 31 additions and 31 deletions

View File

@ -29,19 +29,19 @@ function onAdjust(name, value) {
function onSearch() { function onSearch() {
var params = { var params = {
'keyword': $('#keyword').val(), keyword: $('#keyword').val(),
'minScore': parseInt($('#minScore').val()), searchRange: { min: -1.0, max: 1.0 },
'hintSteps': parseInt($('#hintSteps').val()), minScore: parseInt($('#minScore').val()),
'maxResults': parseInt($('#maxResults').val()), hintSteps: parseInt($('#hintSteps').val()),
'useLocalScale': true, maxResults: parseInt($('#maxResults').val()),
'useRelativeScale': true useLocalScale: true,
useRelativeScale: true
}; };
$.getJSON('/node/search', params, function(results) { $.getJSON('/node/search', params, function(results) {
console.log(results);
window.adjuster = { window.adjuster = {
searchParams: results.params, searchParams: results.params,
searchRange: params.searchRange,
minScore: params.minScore, minScore: params.minScore,
hintSteps: params.hintSteps, hintSteps: params.hintSteps,
maxResults: params.maxResults maxResults: params.maxResults
@ -51,8 +51,7 @@ function onSearch() {
window.grapher.setColumns(results.columns); window.grapher.setColumns(results.columns);
window.grapher.setValueChangedListener(onAdjust); window.grapher.setValueChangedListener(onAdjust);
// var results = searchData(searchParams, minScore); outputResults(results.items, params.maxResults);
// outputResults(results, maxResults);
$('#query').text(params.keyword); $('#query').text(params.keyword);
$('#useLocalScale').prop('checked', useLocalScale); $('#useLocalScale').prop('checked', useLocalScale);

View File

@ -56,8 +56,8 @@ function searchProjection(searchParams, minScore, feature, range, steps) {
searchStepper(range, steps, function(position) { searchStepper(range, steps, function(position) {
testParams[feature] = position; testParams[feature] = position;
results.push({ results.push({
'sample': position, sample: position,
'values': searchData(testParams, minScore) values: searchData(testParams, minScore)
}); });
}); });
@ -73,9 +73,9 @@ function searchProjection2d(searchParams, minScore, feature1, feature2, range, s
searchStepper(range, steps, function(sampleY) { searchStepper(range, steps, function(sampleY) {
testParams[feature2] = sampleY; testParams[feature2] = sampleY;
results.push({ results.push({
'sampleX': sampleX, sampleX: sampleX,
'sampleY': sampleY, sampleY: sampleY,
'values': searchData(testParams, minScore) values: searchData(testParams, minScore)
}); });
}); });
}); });
@ -95,8 +95,8 @@ function searchBuildHints(searchParams, minScore, feature, range, steps) {
var hints = []; var hints = [];
_.each(projection, function(result) { _.each(projection, function(result) {
hints.push({ hints.push({
'sample': result.sample, sample: result.sample,
'count': result.values.length count: result.values.length
}); });
}); });
@ -116,9 +116,9 @@ function searchBuildHints2d(searchParams, minScore, feature1, feature2, range, s
var hints = []; var hints = [];
_.each(projection, function(result) { _.each(projection, function(result) {
hints.push({ hints.push({
'sampleX': result.sampleX, sampleX: result.sampleX,
'sampleY': result.sampleY, sampleY: result.sampleY,
'count': result.values.length count: result.values.length
}); });
}); });
@ -130,29 +130,30 @@ module.exports.getKeywords = function() {
} }
module.exports.execQuery = function(query) { module.exports.execQuery = function(query) {
var searchParams = db_keywords[query.keyword]; var searchParams = db_keywords[query.keyword];
var searchRange = { 'min': -1.0, 'max': 1.0 }; var searchResults = searchData(searchParams, query.minScore);
var graphColumns = { }; var graphColumns = { };
for (var feature in searchParams) { for (var feature in searchParams) {
var hints = searchBuildHints( var searchHints = searchBuildHints(
searchParams, searchParams,
query.minScore, query.minScore,
feature, feature,
searchRange, query.searchRange,
query.hintSteps query.hintSteps
); );
graphColumns[feature] = { graphColumns[feature] = {
'color': '#607080', color: '#607080',
'value': searchParams[feature], value: searchParams[feature],
'hints': hints, hints: searchHints,
'steps': query.hintSteps steps: query.hintSteps
} }
} }
return { return {
'columns': graphColumns, columns: graphColumns,
'params': searchParams params: searchParams,
items: searchResults
}; };
} }