[Groonga-commit] groonga/gcs [master] search: enable default fields in bq

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Aug 14 17:24:21 JST 2012


Kouhei Sutou	2012-08-14 17:24:21 +0900 (Tue, 14 Aug 2012)

  New Revision: ebe3c1ba873f4ea583d1ef12e3e4be57e000b22e
  https://github.com/groonga/gcs/commit/ebe3c1ba873f4ea583d1ef12e3e4be57e000b22e

  Log:
    search: enable default fields in bq

  Modified files:
    lib/api/2011-02-01/search.js

  Modified: lib/api/2011-02-01/search.js (+11 -15)
===================================================================
--- lib/api/2011-02-01/search.js    2012-08-14 17:23:09 +0900 (8255eed)
+++ lib/api/2011-02-01/search.js    2012-08-14 17:24:21 +0900 (dc369c8)
@@ -96,22 +96,19 @@ exports.createHandler = function(context) {
     var filters = [];
     var matchExpr = "";
     var facetParameter = request.query.facet;
+    var defaultFields = domain.indexFields.filter(function(field) {
+      return field.type == 'text' && field.searchEnabled;
+    });
+    var defaultFieldNames = defaultFields.map(function(field) {
+      return field.name;
+    });
 
     if (query) {
-      var matchIndexFields;
-      var queryFilters;
-      var queryAsBooleanQuery;
-
+      var queryAsBooleanQuery = translateQueryToBooleanQuery(query);
+      var translator = new BooleanQueryTranslator(queryAsBooleanQuery);
+      translator.defaultFieldNames = defaultFieldNames;
       try {
-        queryAsBooleanQuery = translateQueryToBooleanQuery(query);
-        matchIndexFields = domain.indexFields.filter(function(field) {
-          return field.type == 'text' && field.searchEnabled;
-        });
-        queryFilters = matchIndexFields.map(function(field) {
-          var translator = new BooleanQueryTranslator(queryAsBooleanQuery);
-          translator.defaultField = field.columnName;
-          return "(" + translator.translate() + ")";
-        });
+        filters.push(translator.translate());
       } catch (error) {
         var body = createErrorBody({
           rid: dummyRid,
@@ -119,13 +116,12 @@ exports.createHandler = function(context) {
         });
         return response.send(body, 400);
       }
-      filters.push(queryFilters.join(" || "));
       matchExpr = "(label " + queryAsBooleanQuery + ")";
     }
 
     if (booleanQuery) {
       var translator = new BooleanQueryTranslator(booleanQuery);
-      translator.defaultField = "FIXME"
+      translator.defaultFieldNames = defaultFieldNames;
       try {
         filters.push(translator.translate());
       } catch (error) {
-------------- next part --------------
HTML����������������������������...
下載 



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