[Groonga-commit] nroonga/norema [master] Support faceted query

Back to archive index

Yoji SHIDARA null+****@clear*****
Tue Aug 21 16:46:05 JST 2012


Yoji SHIDARA	2012-08-21 16:46:05 +0900 (Tue, 21 Aug 2012)

  New Revision: 9e39ab224a88e4798b097bbfed9a4f89bba3cbce
  https://github.com/nroonga/norema/commit/9e39ab224a88e4798b097bbfed9a4f89bba3cbce

  Log:
    Support faceted query

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

  Modified: lib/server.js (+7 -1)
===================================================================
--- lib/server.js    2012-08-21 16:21:25 +0900 (e9605e2)
+++ lib/server.js    2012-08-21 16:46:05 +0900 (1368f79)
@@ -82,6 +82,11 @@ app.get('/search', function(request, response, next) {
     facet: 'path'
   };
 
+  if (request.query.in) {
+    var facetSpecified = request.query.in;
+    options.bq = "path:'" + facetSpecified + "'"
+  }
+
   console.log('SEARCH', options);
   search(options, function(error, results) {
     if (error) {
@@ -118,7 +123,8 @@ app.get('/search', function(request, response, next) {
       to: start + numReturned,
       numShowing: numReturned,
       nextLink: nextLink,
-      previousLink: previousLink
+      previousLink: previousLink,
+      facetSpecified: facetSpecified
     };
 
     return response.render('search.jade', locals);

  Modified: views/layout.jade (+1 -0)
===================================================================
--- views/layout.jade    2012-08-21 16:21:25 +0900 (d275890)
+++ views/layout.jade    2012-08-21 16:46:05 +0900 (98334d5)
@@ -5,6 +5,7 @@ html
     link(href="/css/bootstrap.min.css", rel="stylesheet")
     link(href="/css/norema.css", rel="stylesheet")
     script(src="/js/jquery-1.7.2.min.js", type="text/javascript")
+    script(src="/js/bootstrap.min.js", type="text/javascript")
     script(src="/js/norema.js", type="text/javascript")
 
   body

  Modified: views/search.jade (+17 -12)
===================================================================
--- views/search.jade    2012-08-21 16:21:25 +0900 (112ec4e)
+++ views/search.jade    2012-08-21 16:46:05 +0900 (06de8d3)
@@ -3,10 +3,16 @@ extends layout
 block navbar
   form(action="search").navbar-search.pull-left
     input(type="text", value=query, name="query", placeholder="Search").input-xlarge#query
+  if facetSpecified
+    p.navbar-text
+      a(href=urlForSearch({query: query}), style='margin-left: 10px;')
+        |  in 
+        strong= facetSpecified
+        |  [X]
 
 block content
   .row
-    .span12
+    .span9
       if records.length > 0
         .alert.alert-info
           | Found #{numFound} entries.
@@ -15,8 +21,6 @@ block content
         .alert.alert-info
           | No entry found.
 
-  .row
-    .span9
       if records.length > 0
         include pager
         each record, index in records
@@ -35,12 +39,13 @@ block content
         include pager
 
     .span3
-      if pathFacets.length > 0
-        .well(style="padding: 8px 0;")
-          ul.nav.nav-list
-            each facet, index in pathFacets
-              li
-                a
-                  = facet.value
-                  | 
-                  span.badge.badge-info= facet.count
+      .side-nav('data-spy'='affix')
+        if pathFacets.length > 0
+          .well(style="padding: 8px 0;")
+            ul.nav.nav-list
+              each facet, index in pathFacets
+                li
+                  a(href=urlForSearch({query: query, in: facet.value}))
+                    = facet.value
+                    | 
+                    span.badge.badge-info= facet.count
-------------- next part --------------
HTML����������������������������...
다운로드 



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