Made search actually work
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/2363359c Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/2363359c Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/2363359c Branch: refs/heads/apache-blur-0.2 Commit: 2363359ca2c07382466bff93c4997c7e4ba10a78 Parents: 2652a45 Author: Chris Rohr <[email protected]> Authored: Thu May 29 15:54:46 2014 -0400 Committer: Chris Rohr <[email protected]> Committed: Thu May 29 15:54:46 2014 -0400 ---------------------------------------------------------------------- .../org/apache/blur/console/JettyServer.java | 1 + .../apache/blur/console/model/ResultRow.java | 48 ++++++ .../apache/blur/console/util/SearchUtil.java | 153 +++++++++++++++---- .../src/main/webapp/js/blurconsole.fake.js | 80 ++++++---- .../src/main/webapp/js/blurconsole.model.js | 19 ++- .../src/main/webapp/js/blurconsole.queries.js | 1 + .../src/main/webapp/js/blurconsole.search.js | 127 ++++++++------- .../src/main/webapp/js/blurconsole.utils.js | 5 + 8 files changed, 307 insertions(+), 127 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2363359c/contrib/blur-console/src/main/java/org/apache/blur/console/JettyServer.java ---------------------------------------------------------------------- diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/JettyServer.java b/contrib/blur-console/src/main/java/org/apache/blur/console/JettyServer.java index 07fccff..b08e8fd 100644 --- a/contrib/blur-console/src/main/java/org/apache/blur/console/JettyServer.java +++ b/contrib/blur-console/src/main/java/org/apache/blur/console/JettyServer.java @@ -62,6 +62,7 @@ public class JettyServer { server = new Server(port); // for localhost:port/console/index.html and whatever else is in the webapp directory + System.out.println(this.getClass().getClassLoader().getResource(DEV_WEBAPPDIR).toString()); final URL warUrl = devMode ? this.getClass().getClassLoader().getResource(DEV_WEBAPPDIR) : this.getClass().getClassLoader().getResource(PROD_WEBAPPDIR); final String warUrlString = warUrl.toExternalForm(); server.setHandler(new WebAppContext(warUrlString, CONTEXTPATH)); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2363359c/contrib/blur-console/src/main/java/org/apache/blur/console/model/ResultRow.java ---------------------------------------------------------------------- diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/model/ResultRow.java b/contrib/blur-console/src/main/java/org/apache/blur/console/model/ResultRow.java new file mode 100644 index 0000000..d92597c --- /dev/null +++ b/contrib/blur-console/src/main/java/org/apache/blur/console/model/ResultRow.java @@ -0,0 +1,48 @@ +package org.apache.blur.console.model; + +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ResultRow { + private String rowid; + private List<Map<String, String>> records = new ArrayList<Map<String, String>>(); + + public ResultRow() { + + } + + public ResultRow(String rowid) { + this.rowid = rowid; + } + + public String getRowid() { + return rowid; + } + public void setRowid(String rowid) { + this.rowid = rowid; + } + public List<Map<String, String>> getRecords() { + return records; + } + public void setRecords(List<Map<String, String>> records) { + this.records = records; + } +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2363359c/contrib/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java ---------------------------------------------------------------------- diff --git a/contrib/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java b/contrib/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java index 78804f1..d19ead7 100644 --- a/contrib/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java +++ b/contrib/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java @@ -7,9 +7,9 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; +import org.apache.blur.console.model.ResultRow; import org.apache.blur.thirdparty.thrift_0_9_0.TException; import org.apache.blur.thrift.BlurClient; import org.apache.blur.thrift.generated.Blur.Iface; @@ -26,6 +26,8 @@ import org.apache.blur.thrift.generated.Record; import org.apache.blur.thrift.generated.Row; import org.apache.blur.thrift.generated.ScoreType; import org.apache.blur.thrift.generated.Selector; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -45,6 +47,12 @@ import org.apache.blur.thrift.generated.Selector; */ public class SearchUtil { + private static final String TOTAL_KEY = "total"; + private static final String DATA_KEY = "results"; + private static final String FAMILY_KEY = "families"; + + private static final String ROW_ROW_OPTION = "rowrow"; + private static final String RECORD_RECORD_OPTION = "recordrecord"; /** * Record only results: @@ -59,20 +67,20 @@ public class SearchUtil { * * Row results: * { - * famName: { - * rowid: [ - * { - * colName: value - * } - * ] - * } + * famName: [ + * { + * rowid: rowid, + * records: [ + * { + * colName: value + * } + * ] + * } + * ] * } */ - @SuppressWarnings("unchecked") public static Map<String, Object> search(Map<String, String[]> params) throws IOException, BlurException, TException { - Iface client = BlurClient.getClient(Config.getConnectionString()); - String table = params.get("table")[0]; String query = params.get("query")[0]; String rowQuery = params.get("rowRecordOption")[0]; @@ -80,11 +88,30 @@ public class SearchUtil { String fetch = params.get("fetch")[0]; String[] families = params.get("families[]"); - boolean recordsOnly = "recordrecord".equalsIgnoreCase(rowQuery); + if (families == null || families.length == 0) { + return fullTextSearch(table, query); + } + + if (ArrayUtils.contains(families, "rowid")) { + return fetchRow(table, query, families); + } + + if (ArrayUtils.contains(families, "recordid")) { + return fetchRecord(table, query, families); + } + + return searchAndFetch(table, query, rowQuery, start, fetch, families); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private static Map<String, Object> searchAndFetch(String table, String query, String rowQuery, String start, String fetch, String[] families) throws IOException, BlurException, TException { + Iface client = BlurClient.getClient(Config.getConnectionString()); + + boolean recordsOnly = RECORD_RECORD_OPTION.equalsIgnoreCase(rowQuery); BlurQuery blurQuery = new BlurQuery(); - Query q = new Query(query, "rowrow".equalsIgnoreCase(rowQuery), ScoreType.SUPER, null, null); + Query q = new Query(query, ROW_ROW_OPTION.equalsIgnoreCase(rowQuery), ScoreType.SUPER, null, null); blurQuery.setQuery(q); blurQuery.setStart(Long.parseLong(start)); blurQuery.setFetch(Integer.parseInt(fetch)); @@ -97,10 +124,9 @@ public class SearchUtil { BlurResults blurResults = client.query(table, blurQuery); Map<String, Object> results = new HashMap<String, Object>(); - results.put("total", blurResults.getTotalResults()); + results.put(TOTAL_KEY, blurResults.getTotalResults()); - Set<String> fams = new HashSet<String>(); - Map<String, Object> rows = new HashMap<String, Object>(); + Map<String, List> rows = new HashMap<String, List>(); for (BlurResult result : blurResults.getResults()) { FetchResult fetchResult = result.getFetchResult(); @@ -110,7 +136,6 @@ public class SearchUtil { Record record = recordResult.getRecord(); String family = record.getFamily(); - fams.add(family); List<Map<String, String>> fam = (List<Map<String, String>>) getFam(family, rows, recordsOnly); fam.add(buildRow(record.getColumns(), record.getRecordId())); @@ -118,23 +143,78 @@ public class SearchUtil { // Row Result FetchRowResult rowResult = fetchResult.getRowResult(); Row row = rowResult.getRow(); - for (Record record : row.getRecords()) { - String family = record.getFamily(); - fams.add(family); - - Map<String, List<Map<String, String>>> fam = (Map<String, List<Map<String, String>>>) getFam(family, rows, recordsOnly); - List<Map<String, String>> rowData = getRow(row.getId(), fam); - rowData.add(buildRow(record.getColumns(), record.getRecordId())); + if (row.getRecords() == null || row.getRecords().size() == 0) { + for(String family : families) { + List<ResultRow> fam = (List<ResultRow>) getFam(family, rows, recordsOnly); + getRow(row.getId(), fam); + } + } else { + for (Record record : row.getRecords()) { + String family = record.getFamily(); + + List<ResultRow> fam = (List<ResultRow>) getFam(family, rows, recordsOnly); + ResultRow rowData = getRow(row.getId(), fam); + rowData.getRecords().add(buildRow(record.getColumns(), record.getRecordId())); + } } } } - results.put("families", fams); - results.put("results", rows); + results.put(FAMILY_KEY, new HashSet<String>(Arrays.asList(families))); + results.put(DATA_KEY, rows); return results; } + private static Map<String, Object> fullTextSearch(String table, String query) throws IOException, BlurException, TException { + Iface client = BlurClient.getClient(Config.getConnectionString()); + + BlurQuery blurQuery = new BlurQuery(); + + Query q = new Query(query, true, ScoreType.SUPER, null, null); + blurQuery.setQuery(q); + BlurResults blurResults = client.query(table, blurQuery); + + Map<String, Object> results = new HashMap<String, Object>(); + results.put(TOTAL_KEY, blurResults.getTotalResults()); + return results; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private static Map<String, Object> fetchRow(String table, String query, String[] families) throws IOException, BlurException, TException { + Iface client = BlurClient.getClient(Config.getConnectionString()); + Selector selector = new Selector(); + String rowid = StringUtils.remove(query, "rowid:"); + selector.setRowId(rowid); + selector.setColumnFamiliesToFetch(new HashSet<String>(Arrays.asList(families))); + + FetchResult fetchRow = client.fetchRow(table, selector); + + Map<String, Object> results = new HashMap<String, Object>(); + results.put(TOTAL_KEY, fetchRow.getRowResult().getRow() == null ? 0 : 1); + + Map<String, List> rows = new HashMap<String, List>(); + Row row = fetchRow.getRowResult().getRow(); + if (row != null) { + for (Record record : row.getRecords()) { + String family = record.getFamily(); + + List<ResultRow> fam = (List<ResultRow>) getFam(family, rows, false); + ResultRow rowData = getRow(row.getId(), fam); + rowData.getRecords().add(buildRow(record.getColumns(), record.getRecordId())); + } + } + results.put(DATA_KEY, rows); + results.put(FAMILY_KEY, new HashSet<String>(Arrays.asList(families))); + + return null; + } + + private static Map<String, Object> fetchRecord(String table, String query, String[] families) throws IOException { +// Iface client = BlurClient.getClient(Config.getConnectionString()); + return null; + } + private static Map<String, String> buildRow(List<Column> columns, String recordid) { Map<String, String> map = new TreeMap<String, String>(); map.put("recordid", recordid); @@ -146,14 +226,15 @@ public class SearchUtil { return map; } - private static Object getFam(String fam, Map<String, Object> results, boolean recordOnly) { - Object famResults = results.get(fam); + @SuppressWarnings("rawtypes") + private static List getFam(String fam, Map<String, List> results, boolean recordOnly) { + List famResults = results.get(fam); if (famResults == null) { if (recordOnly) { famResults = new ArrayList<Map<String, String>>(); } else { - famResults = new TreeMap<String, List<Map<String, String>>>(); + famResults = new ArrayList<ResultRow>(); } results.put(fam, famResults); } @@ -161,12 +242,18 @@ public class SearchUtil { return famResults; } - private static List<Map<String, String>> getRow(String rowid, Map<String, List<Map<String, String>>> rows) { - List<Map<String, String>> row = rows.get(rowid); + private static ResultRow getRow(String rowid, List<ResultRow> rows) { + ResultRow row = null; + for(ResultRow r : rows) { + if (r.getRowid().equals(rowid)) { + row = r; + break; + } + } if (row == null) { - row = new ArrayList<Map<String, String>>(); - rows.put(rowid, row); + row = new ResultRow(rowid); + rows.add(row); } return row; http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2363359c/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js ---------------------------------------------------------------------- diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js b/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js index b34f3b9..84fb382 100644 --- a/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js +++ b/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js @@ -176,46 +176,60 @@ blurconsole.fake = (function() { sendSearch = function(query, table, args, callback) { console.log('sending fake search [' + query + '] on table [' + table + ']'); - var fams = args.families, results = {}, total = randomNumber(1000); + var fams = args.families, results = {}, total = (fams !== null && fams.indexOf('rowid') >= 0) ? 1 : randomNumber(1000); - $.each(fams, function(i, fam){ - var cols = randomNumber(30, true), toFetch = args.fetch; - if (total - args.start < toFetch) { - toFetch = total - args.start; - } + if (fams !== null) { + $.each(fams, function(i, fam){ + var cols = randomNumber(30, true), toFetch = (fams !== null && fams.indexOf('rowid') >= 0)? 1 : args.fetch; + if (total - args.start < toFetch) { + toFetch = total - args.start; + } - if (args.rowRecordOption === 'recordrecord') { - results[fam] = []; - for (var recordIndex = 0; recordIndex < randomNumber(toFetch); recordIndex++) { - var recordRow = {}; - recordRow.recordid = randomNumber(1000000).toString(); - for (var recordColIndex=0; recordColIndex < cols; recordColIndex++) { - recordRow['col'+recordColIndex] = randomString(); + if (args.rowRecordOption === 'recordrecord') { + results[fam] = []; + for (var recordIndex = 0; recordIndex < randomNumber(toFetch); recordIndex++) { + var recordRow = {}; + recordRow.recordid = randomNumber(1000000).toString(); + for (var recordColIndex=0; recordColIndex < cols; recordColIndex++) { + recordRow['col'+recordColIndex] = randomString(); + } + results[fam].push(recordRow); } - results[fam].push(recordRow); - } - } else { - results[fam] = {}; - for (var rowIndex = 0; rowIndex < randomNumber(toFetch); rowIndex++) { - var rowid = randomNumber(10000000).toString(); - results[fam][rowid] = []; - for (var rowRecordIndex = 0; rowRecordIndex < randomNumber(10); rowRecordIndex++) { - var row = {}; - row.recordid = randomNumber(1000000).toString(); - for (var rowRecordColIndex=0; rowRecordColIndex < cols; rowRecordColIndex++) { - row['col'+rowRecordColIndex] = randomString(); + } else { + results[fam] = {}; + for (var rowIndex = 0; rowIndex < randomNumber(toFetch); rowIndex++) { + var rowid = randomNumber(10000000).toString(); + results[fam][rowid] = []; + for (var rowRecordIndex = 0; rowRecordIndex < randomNumber(10); rowRecordIndex++) { + var row = {}; + row.recordid = randomNumber(1000000).toString(); + for (var rowRecordColIndex=0; rowRecordColIndex < cols; rowRecordColIndex++) { + row['col'+rowRecordColIndex] = randomString(); + } + results[fam][rowid].push(row); } - results[fam][rowid].push(row); } } - } - }); + }); + } - callback({ - families: fams, - results: results, - total: total - }); + if (fams === null || fams.length === 0) { + callback({ + total: total + }); + } else if (fams.indexOf('rowid') >= 0) { + callback({ + total: total, + results: results, + families: fams + }); + } else { + callback({ + families: fams, + results: results, + total: total + }); + } }; randomNumber = function(max, includeZero) { http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2363359c/contrib/blur-console/src/main/webapp/js/blurconsole.model.js ---------------------------------------------------------------------- diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js b/contrib/blur-console/src/main/webapp/js/blurconsole.model.js index c85d006..31ed564 100644 --- a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js +++ b/contrib/blur-console/src/main/webapp/js/blurconsole.model.js @@ -391,7 +391,15 @@ blurconsole.model = (function() { loadMoreResults = function(family) { var alreadyLoadedResults = results[family]; - currentArgs.start = alreadyLoadedResults ? alreadyLoadedResults.length : 0; + if (typeof alreadyLoadedResults === 'undefined' || alreadyLoadedResults === null) { + currentArgs.start = 0; + } else if ($.isArray(alreadyLoadedResults)) { + currentArgs.start = alreadyLoadedResults.length; + } else { + currentArgs.start = blurconsole.utils.keys(alreadyLoadedResults).length; + } + + // currentArgs.start = alreadyLoadedResults ? alreadyLoadedResults.length : 0; currentArgs.fetch = 10; currentArgs.families = [family]; sendSearch(); @@ -410,13 +418,8 @@ blurconsole.model = (function() { if (typeof dataResults !== 'undefined' && dataResults !== null) { $.each(dataResults, function(family, resultList){ - if (currentArgs.rowRecordOption === 'recordrecord') { - var recordList = results[family] || []; - results[family] = recordList.concat(resultList); - } else { - var rowList = results[family] || {}; - results[family] = $.extend(resultList, rowList); - } + var dataList = results[family] || []; + results[family] = dataList.concat(resultList); }); } $.gevent.publish('results-updated', [dataFamilies]); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2363359c/contrib/blur-console/src/main/webapp/js/blurconsole.queries.js ---------------------------------------------------------------------- diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.queries.js b/contrib/blur-console/src/main/webapp/js/blurconsole.queries.js index 256abaf..cfda508 100644 --- a/contrib/blur-console/src/main/webapp/js/blurconsole.queries.js +++ b/contrib/blur-console/src/main/webapp/js/blurconsole.queries.js @@ -160,6 +160,7 @@ blurconsole.queries = (function () { var clusters = blurconsole.model.tables.getClusters(); if (clusters && clusters.length > 0) { drawTableList(); + drawQueries(); } else { setTimeout(waitForData, 100); } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2363359c/contrib/blur-console/src/main/webapp/js/blurconsole.search.js ---------------------------------------------------------------------- diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.search.js b/contrib/blur-console/src/main/webapp/js/blurconsole.search.js index 64f6a79..212ac02 100644 --- a/contrib/blur-console/src/main/webapp/js/blurconsole.search.js +++ b/contrib/blur-console/src/main/webapp/js/blurconsole.search.js @@ -202,7 +202,7 @@ blurconsole.search = (function () { fixPanelWidths = function() { var allPanels = jqueryMap.$resultsHolder.find('.panel-collapse'); if (allPanels.length > 0) { - var width = $(allPanels[0]).width(); + var width = $(allPanels[0]).parent().width() - 30; allPanels.width(width); } }; @@ -212,70 +212,91 @@ blurconsole.search = (function () { jqueryMap.$countHolder.html('<small>Found ' + blurconsole.model.search.getTotal() + ' total results</small>'); //jqueryMap.$facetTrigger.show(); - $.each(families, function(i, fam) { - var famResults = results[fam], - famId = '#' + blurconsole.browserUtils.cleanId(fam), - famHolder = $(famId + ' .panel-body'), - table = '<table class="table table-condensed table-hover table-bordered"><thead><tr>', - cols, famTotal; + if (typeof families !== 'undefined' && families !== null) { + $.each(families, function(i, fam) { + var famResults = results[fam], + famId = '#' + blurconsole.browserUtils.cleanId(fam), + famHolder = $(famId + ' .panel-body'), + table = '<table class="table table-condensed table-hover table-bordered"><thead><tr>', + cols; + + if (famResults.length === 0) { + famHolder.html('<div class="alert alert-info">No Data Found</div>'); + } else { + if (blurconsole.utils.keys(famResults[0]).indexOf('rowid') === -1 ) { + // Record results + cols = getColList(famResults[0]); + + $.each(cols, function(i, col) { + table += '<th>' + col + '</th>'; + }); + table += '</tr></thead><tbody>'; + $.each(famResults, function(i, row) { + table += '<tr>'; + $.each(cols, function(c, col) { + table += '<td>' + (row[col] || '') + '</td>'; + }); + table += '</tr>'; + }); + } else { + // Row results + $.each(famResults, function(i, row){ + if (row.records.length > 0) { + var tmpCols = getColList(row.records[0]); + if (tmpCols.length > 0) { + cols = tmpCols; + return false; + } + } + }); - if ($.isArray(famResults)) { - // Record results - cols = getColList(famResults[0]); + cols = cols || []; - $.each(cols, function(i, col) { - table += '<th>' + col + '</th>'; - }); - table += '</tr></thead><tbody>'; - $.each(famResults, function(i, row) { - table += '<tr>'; - $.each(cols, function(c, col) { - table += '<td>' + (row[col] || '') + '</td>'; - }); - table += '</tr>'; - }); - famTotal = famResults.length; - } else { - // Row results - var rowids = blurconsole.utils.keys(famResults); - var firstRow = famResults[rowids[0]]; - cols = getColList(firstRow[0]); - - $.each(cols, function(i, col) { - table += '<th>' + col + '</th>'; - }); - table += '</tr></thead><tbody>'; - $.each(famResults, function(rowid, records) { - table += '<tr class="row-separator"><td colspan="' + cols.length + '"><strong>rowid:</strong> ' + rowid + ' (<em>' + records.length + ' records</em>)</td></tr>'; - $.each(records, function(i, rec) { - table += '<tr>'; - $.each(cols, function(c, col) { - table += '<td>' + (rec[col] || '') + '</td>'; + $.each(cols, function(i, col) { + table += '<th>' + col + '</th>'; }); - table += '</tr>'; - }); - }); - famTotal = rowids.length; - } + table += '</tr></thead><tbody>'; + $.each(famResults, function(r, row) { + table += '<tr class="row-separator"><td colspan="' + (cols.length === 0 ? 1 : cols.length) + '">' + (r+1) + '. <strong>rowid:</strong> ' + row.rowid + ' (<em>' + (row.records === null ? 0 : row.records.length) + ' records</em>)</td></tr>'; + if (row.records === null || row.records.length === 0) { + table += '<tr><td colspan="' + (cols.length === 0 ? 1 : cols.length) + '"><em>No Data Found</em></td></tr>'; + } else { + $.each(row.records, function(i, rec) { + table += '<tr>'; + $.each(cols, function(c, col) { + table += '<td>' + (rec[col] || '') + '</td>'; + }); + table += '</tr>'; + }); + } + }); + } - table += '</tbody></table>'; + table += '</tbody></table>'; - if (famTotal < blurconsole.model.search.getTotal()) { - table += '<div class="pull-left"><a href="' + famId + '" class="btn btn-primary nextPage">Load More...</a></div>'; - } + if (famResults.length < blurconsole.model.search.getTotal()) { + table += '<div class="pull-left"><a href="' + famId + '" class="btn btn-primary nextPage">Load More...</a></div>'; + } - famHolder.html(table); - if (!$(famId).hasClass('loaded')) { - $(famId).addClass('loaded'); - } - }); - fixPanelWidths(); + famHolder.html(table); + } + if (!$(famId).hasClass('loaded')) { + $(famId).addClass('loaded'); + } + }); + fixPanelWidths(); + } }; getColList = function(row) { var cols = blurconsole.utils.reject(blurconsole.utils.keys(row), function(i) { return i === 'recordid'; }); + + if (cols.length === 0) { + return []; + } + cols.sort(); cols = ['recordid'].concat(cols); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2363359c/contrib/blur-console/src/main/webapp/js/blurconsole.utils.js ---------------------------------------------------------------------- diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.utils.js b/contrib/blur-console/src/main/webapp/js/blurconsole.utils.js index 216079c..f98939f 100644 --- a/contrib/blur-console/src/main/webapp/js/blurconsole.utils.js +++ b/contrib/blur-console/src/main/webapp/js/blurconsole.utils.js @@ -62,6 +62,11 @@ blurconsole.utils = (function(){ findFamilies = function(query) { // Determine regex to find column families in lucene query var matches = query.match(/[^ \(\)\+\-]+(\w+)\.\w+:/g); + + if (matches === null) { + return []; + } + var families = []; $.each(matches, function(idx, match) { families.push(match.split('.')[0]);
