incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject git commit: Got all of the search options working
Date Mon, 09 Jun 2014 18:41:21 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/apache-blur-0.2 15e8c679b -> 3fed5359f


Got all of the search options working


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/3fed5359
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/3fed5359
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/3fed5359

Branch: refs/heads/apache-blur-0.2
Commit: 3fed5359fc95e431d00ac8dd83eea6027aec3607
Parents: 15e8c67
Author: Chris Rohr <rohr.chris@gmail.com>
Authored: Mon Jun 9 14:41:13 2014 -0400
Committer: Chris Rohr <rohr.chris@gmail.com>
Committed: Mon Jun 9 14:41:13 2014 -0400

----------------------------------------------------------------------
 .../apache/blur/console/util/SearchUtil.java    | 44 ++------------------
 .../src/main/webapp/js/blurconsole.fake.js      | 12 +++---
 .../src/main/webapp/js/blurconsole.model.js     |  9 ++--
 .../src/main/webapp/js/blurconsole.search.js    | 26 +++++++-----
 .../main/webapp/sass/blurconsole.search.scss    |  4 +-
 5 files changed, 32 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3fed5359/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 b0a07b7..6a72340 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
@@ -26,7 +26,6 @@ import org.apache.blur.thrift.generated.Row;
 import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.blur.thrift.generated.Selector;
 import org.apache.blur.user.UserContext;
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 
 /**
@@ -62,16 +61,12 @@ public class SearchUtil {
 		String fetch = params.get("fetch")[0];
 		String[] families = params.get("families[]");
 		
-		if (families == null || families.length == 0) {
-			return fullTextSearch(table, query, remoteHost);
-		}
-		
-		if (ArrayUtils.contains(families, "rowid")) {
+		if (query.indexOf("rowid:") >= 0) {
 			return fetchRow(table, query, families, remoteHost);
 		}
 		
-		if (ArrayUtils.contains(families, "recordid")) {
-			return fetchRecord(table, query, families, remoteHost);
+		if (families == null || families.length == 0) {
+			return fullTextSearch(table, query, remoteHost);
 		}
 		
 		return searchAndFetch(table, query, rowQuery, start, fetch, families, remoteHost);
@@ -197,39 +192,6 @@ public class SearchUtil {
 		}
 	}
 	
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	private static Map<String, Object> fetchRecord(String table, String query, String[]
families, String remoteHost) throws IOException, BlurException, TException {
-		try {
-			Iface client = Config.getClient(remoteHost);
-			
-			Selector selector = new Selector();
-			String recordId = StringUtils.remove(query, "recordid:");
-			selector.setRecordId(recordId);
-			selector.setRecordOnly(true);
-			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.getRecordResult().getRecord() == null ? 0 : 1);
-			
-			Map<String, List> rows = new HashMap<String, List>();
-			Record record = fetchRow.getRecordResult().getRecord();
-			if (record != null) {
-				String family = record.getFamily();
-					
-				List<Map<String, String>> fam = (List<Map<String, String>>) getFam(family,
rows, true);
-				fam.add(buildRow(record.getColumns(), record.getRecordId()));
-			}
-			results.put(DATA_KEY, rows);
-			results.put(FAMILY_KEY, new HashSet<String>(Arrays.asList(families)));
-			
-			return results;
-		} finally {
-			UserContext.reset();
-		}
-	}
-	
 	private static Map<String, String> buildRow(List<Column> columns, String recordid)
{
 		Map<String, String> map = new TreeMap<String, String>();
 		map.put("recordid", recordid);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3fed5359/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 bb4b247..fc07b1d 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
@@ -208,27 +208,27 @@ blurconsole.fake = (function() {
 						results[fam].push(recordRow);
 					}
 				} else {
-					results[fam] = {};
+					results[fam] = [];
 					for (var rowIndex = 0; rowIndex < _randomNumber(toFetch); rowIndex++) {
 						var rowid = _randomNumber(10000000).toString();
-						results[fam][rowid] = [];
+						results[fam][rowIndex] = {rowid: rowid, records: []};
 						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][rowIndex]['records'].push(row);
 						}
 					}
 				}
 			});
 		}
 
-		if (fams === null || fams.length === 0) {
-			_sendCallback(callback, { total: total });
-		} else if (fams.indexOf('rowid') >= 0) {
+		if (fams.indexOf('rowid') >= 0) {
 			_sendCallback(callback, { total: total, results: results, families: fams });
+		} else if (fams === null || fams.length === 0) {
+			_sendCallback(callback, { total: total });
 		} else {
 			_sendCallback(callback, { families: fams, results: results, total: total });
 		}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3fed5359/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 45e6866..5eca890 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -409,11 +409,12 @@ blurconsole.model = (function() {
 			currentQuery = query;
 			currentTable = table;
 			currentArgs = $.extend(currentArgs, searchArgs);
-			if (parsedFamilies.length > 0) {
-				currentArgs.families = parsedFamilies;
-			}
+			currentArgs.families = parsedFamilies;
 			results = {};
-			_sendSearch();
+
+			if (query.indexOf('rowid:') === -1 && query.indexOf('recordid:') === -1) {
+				_sendSearch();
+			}
 		}
 
 		function getResults() {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3fed5359/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 63b6bd8..d6c7077 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.search.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.search.js
@@ -149,6 +149,7 @@ blurconsole.search = (function () {
 			}
 		});
 		_drawResultHolders();
+		jqueryMap.$countHolder.html('');
 		blurconsole.model.search.runSearch(stateMap.$currentQuery, stateMap.$currentTable, {start:
0, fetch: 10, rowRecordOption: stateMap.$rowRecordOption});
 	}
 
@@ -224,15 +225,16 @@ blurconsole.search = (function () {
 			$.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;
+					famHolder = $(famId + ' .panel-body');
 
 				if (typeof famResults === 'undefined' || famResults.length === 0) {
 					famHolder.html('<div class="alert alert-info">No Data Found</div>');
 				} else {
+					var table;
+					var cols;
 					if (blurconsole.utils.keys(famResults[0]).indexOf('rowid') === -1 ) {
 						// Record results
+						table = '<table class="table table-condensed table-hover table-bordered"><thead><tr>';
 						cols = _getColList(famResults[0]);
 
 						$.each(cols, function(i, col) {
@@ -246,6 +248,7 @@ blurconsole.search = (function () {
 							});
 							table += '</tr>';
 						});
+						table += '</tbody></table>';
 					} else {
 						// Row results
 						$.each(famResults, function(i, row){
@@ -259,13 +262,17 @@ blurconsole.search = (function () {
 						});
 
 						cols = cols || [];
+						table = '';
 
-						$.each(cols, function(i, col) {
-							table += '<th>' + col + '</th>';
-						});
-						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>';
+							table += '<table class="table table-condensed table-hover table-bordered"><thead>';
+							table += '<tr class="row-separator"><th colspan="' + (cols.length === 0 ?
1 : cols.length) + '">' + (r+1) + '. <strong>rowid:</strong> ' + row.rowid
+ ' (<em>' + (row.records === null ? 0 : row.records.length) + ' records</em>)</th></tr>';
+							table += '<tr>';
+							$.each(cols, function(i, col) {
+								table += '<th>' + col + '</th>';
+							});
+							table += '</tr></thead><tbody>';
+
 							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 {
@@ -277,11 +284,10 @@ blurconsole.search = (function () {
 									table += '</tr>';
 								});
 							}
+							table += '</tbody></table>';
 						});
 					}
 
-					table += '</tbody></table>';
-
 					if (famResults.length < blurconsole.model.search.getTotal()) {
 						table += '<div class="pull-left"><a href="' + famId + '" class="btn btn-primary
nextPage">Load More...</a></div>';
 					}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3fed5359/contrib/blur-console/src/main/webapp/sass/blurconsole.search.scss
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/sass/blurconsole.search.scss b/contrib/blur-console/src/main/webapp/sass/blurconsole.search.scss
index 65e0369..7c57929 100644
--- a/contrib/blur-console/src/main/webapp/sass/blurconsole.search.scss
+++ b/contrib/blur-console/src/main/webapp/sass/blurconsole.search.scss
@@ -35,10 +35,10 @@ under the License.
 }
 
 tr.row-separator {
-	td {
+	th {
 		background-color: $dusty-gray;
 	}
-	&:hover td {
+	&:hover th {
 		background-color: $dusty-gray !important;
 	}
 }
\ No newline at end of file


Mime
View raw message