[Groonga-commit] groonga/gcs [master] Add test for multiple words matching about literal column

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Aug 23 12:55:33 JST 2012


YUKI Hiroshi	2012-08-23 12:55:33 +0900 (Thu, 23 Aug 2012)

  New Revision: 7d762bcbd6c54df71876428d207e3f31a86be23c
  https://github.com/groonga/gcs/commit/7d762bcbd6c54df71876428d207e3f31a86be23c

  Log:
    Add test for multiple words matching about literal column

  Modified files:
    test/bq-translator.test.js

  Modified: test/bq-translator.test.js (+31 -6)
===================================================================
--- test/bq-translator.test.js    2012-08-23 12:12:27 +0900 (9b4b5fd)
+++ test/bq-translator.test.js    2012-08-23 12:55:33 +0900 (394f546)
@@ -4,21 +4,19 @@ var utils = require('./test-utils');
 var assert = require('chai').assert;
 
 var BooleanQueryTranslator = require('../lib/bq-translator').BooleanQueryTranslator;
+var Domain = require('../lib/database').Domain;
 
 function createTranslator(query) {
   var translator = new BooleanQueryTranslator(query);
-  translator.domain = {
-    getSynonymSync: function(key) {
-      return null;
-    }
-  };
+  translator.domain = domain;
   translator.defaultFieldNames = ["field"];
   return translator;
 }
 
-function testQuery(label, query, expected) {
+function testQuery(label, query, expected, customSetup) {
   test('query: ' + label + ': ' +
        '<' + query + '> -> <' + expected + '>', function() {
+    if (customSetup) customSetup();
     var translator = createTranslator(query);
     assert.equal(translator.translate(),
                  expected);
@@ -150,10 +148,37 @@ function testSynonym(label, query, synonyms, expected) {
   });
 }
 
+var context;
+var temporaryDatabase;
+var domain;
+
 suite('BoolanQueryTranslator', function() {
+  setup(function() {
+    temporaryDatabase = utils.createTemporaryDatabase();
+    context = temporaryDatabase.get();
+    domain = new Domain('test', context).createSync();
+  });
+
+  teardown(function() {
+    context = undefined;
+    temporaryDatabase.clear();
+    temporaryDatabase.teardown();
+    temporaryDatabase = undefined;
+  });
+
   testQuery("expression",
             "type:'ModelName'",
             'type @ "ModelName"');
+  testQuery("multiple words expression",
+            "type:'Model Name'",
+            'type @ "Model" && type @ "Name"');
+  testQuery("multiple words expression for literal column",
+            "literalfield:'Model Name'",
+            'literalfield == "Model Name"',
+            function() {
+              domain.getIndexField('literalfield').setType('literal')
+               .setFacetEnabled(true).setSearchEnabled(true).createSync();
+            });
   testQuery("group: raw expressions",
             "(and field1:'keyword1' field2:'keyword2' type:'ModelName')",
             '(field1 @ "keyword1" && field2 @ "keyword2" && type @ "ModelName")');
-------------- next part --------------
HTML����������������������������...
다운로드 



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