[Groonga-commit] nroonga/norema [master] Show facet

Back to archive index

Yoji SHIDARA null+****@clear*****
Wed Aug 15 13:34:04 JST 2012


Yoji SHIDARA	2012-08-15 13:34:04 +0900 (Wed, 15 Aug 2012)

  New Revision: 69f7960016a89b30eb91d8626cf31a8aa2f43bba
  https://github.com/nroonga/norema/commit/69f7960016a89b30eb91d8626cf31a8aa2f43bba

  Log:
    Show facet
    
    only showing at this time

  Modified files:
    lib/server.js
    views/search.jade

  Modified: lib/server.js (+2 -1)
===================================================================
--- lib/server.js    2012-08-14 19:48:52 +0900 (c8938da)
+++ lib/server.js    2012-08-15 13:34:04 +0900 (fde6133)
@@ -29,7 +29,7 @@ app.use(function(error, request, response, next){
 
 // helpers
 function search(query, callback) {
-  var url = 'http://' + searchNode + '/2011-02-01/search?size=100&q=' + encodeURIComponent(query);
+  var url = 'http://' + searchNode + '/2011-02-01/search?size=100&facet=path&q=' + encodeURIComponent(query);
   var buffer = '';
   var request = http.get(url, function(response) {
     if (response.statusCode !== 200) {
@@ -72,6 +72,7 @@ app.get('/search', function(request, response, next) {
       query: query,
       records: results.hits.hit,
       num_found: results.hits.found,
+      path_facets: results.facets.path.constraints,
       from: results.hits.start + 1,
       to: results.hits.start + results.hits.hit.length,
       num_showing: results.hits.hit.length

  Modified: views/search.jade (+31 -17)
===================================================================
--- views/search.jade    2012-08-14 19:48:52 +0900 (dec7d1c)
+++ views/search.jade    2012-08-15 13:34:04 +0900 (01aae7c)
@@ -1,22 +1,36 @@
 extends layout
 
 block content
-  if records.length > 0
-    .alert.alert-info
-      | Found #{num_found} entries.
-      | Showing #{from} - #{to} (#{num_showing} entries).
+  .row
+    .span12
+      if records.length > 0
+        .alert.alert-info
+          | Found #{num_found} entries.
+          | Showing #{from} - #{to} (#{num_showing} entries).
+      else
+        .alert.alert-info
+          | No entry found.
+  .row
+    .span9
+      if records.length > 0
+        each record, index in records
+          .record
+            h2 #{record.data.title}
+            p.path
+              each title, pathIndex in record.data.path
+                span.label.label-inverse
+                  = title
+                if pathIndex != record.data.path.length - 1
+                  span  » 
 
-    each record, index in records
-      .record
-        h2 #{record.data.title}
-        p.path
-          each title, pathIndex in record.data.path
-            span.label.label-inverse
-              = title
-            if pathIndex != record.data.path.length - 1
-              span  » 
+            !{record.data.desc}
 
-        !{record.data.desc}
-  else
-    .alert.alert-info
-      | No entry found.
+    .span3
+      .well(style="padding: 8px 0;")
+        ul.nav.nav-list
+          each facet, index in path_facets
+            li
+              a
+                = facet.value
+                | 
+                span.badge.badge-info= facet.count
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index