[Groonga-commit] groonga/gcs [master] Add cs-index-documents command

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 6日 (月) 17:48:42 JST


SHIMODA Hiroshi	2012-08-06 17:48:42 +0900 (Mon, 06 Aug 2012)

  New Revision: 517498336fa7329bce9b4b8912cd664b5d51fea1
  https://github.com/groonga/gcs/commit/517498336fa7329bce9b4b8912cd664b5d51fea1

  Log:
    Add cs-index-documents command

  Added files:
    bin/cs-index-documents
  Modified files:
    test/cs-commands.test.js

  Added: bin/cs-index-documents (+26 -0) 100755
===================================================================
--- /dev/null
+++ bin/cs-index-documents    2012-08-06 17:48:42 +0900 (29d3524)
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+
+var CLI = require(__dirname + '/../lib/command-line').CommandLineInterface;
+var commandLine = new CLI();
+
+commandLine
+  .usage('--domain-name <domain name> [options]')
+  .option('-d, --domain-name <domain name>',
+          'The name of the domain that you are indexing. Required.',
+          String)
+  .parse();
+
+commandLine.assertHaveDomainName();
+commandLine.assertDomainExists();
+
+commandLine.domain.reindexSync();
+
+console.log('===========================================');
+console.log('Indexing documents for domain [' + commandLine.domain.name + ']');
+console.log('');
+console.log('Now indexing fields:');
+console.log('===========================================');
+commandLine.domain.indexFields.forEach(function(field) {
+  console.log(field.name);
+});
+console.log('===========================================');

  Modified: test/cs-commands.test.js (+84 -0)
===================================================================
--- test/cs-commands.test.js    2012-08-06 17:40:02 +0900 (705ffbb)
+++ test/cs-commands.test.js    2012-08-06 17:48:42 +0900 (caceb00)
@@ -418,3 +418,87 @@ suite('cs-configure-fields', function() {
       });
   });
 });
+
+suite('cs-index-documents', function() {
+  setup(commonSetup);
+  teardown(commonTeardown);
+
+  test('reindex', function(done) {
+    utils
+      .run('cs-create-domain',
+           '--domain-name', 'companies',
+           '--database-path', temporaryDatabase.path)
+      .run('cs-configure-fields',
+           '--domain-name', 'companies',
+           '--name', 'name',
+           '--type', 'text',
+           '--database-path', temporaryDatabase.path)
+      .run('cs-configure-fields',
+           '--domain-name', 'companies',
+           '--name', 'age',
+           '--type', 'uint',
+           '--database-path', temporaryDatabase.path)
+      .run('cs-configure-fields',
+           '--domain-name', 'companies',
+           '--name', 'product',
+           '--type', 'literal',
+           '--database-path', temporaryDatabase.path)
+      .run('cs-index-documents',
+           '--domain-name', 'companies',
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assert.deepEqual({ code:    result.code,
+                           message: result.output.stdout },
+                         { code:    0,
+                           message: '===========================================\n' +
+                                    'Indexing documents for domain [companies]\n' +
+                                    '\n' +
+                                    'Now indexing fields:\n' +
+                                    '===========================================\n' +
+                                    'age\n' +
+                                    'name\n' +
+                                    'product\n' +
+                                    '===========================================\n',
+                         result.output.stderr);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+
+  test('reindex not-existing domain', function(done) {
+    utils
+      .run('cs-index-documents',
+           '--domain-name', 'test',
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assert.deepEqual({ code:    result.code,
+                           message: result.output.stdout },
+                         { code:    1,
+                           message: 'You must specify an existing domain name.\n' },
+                         result.output.stderr);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+
+  test('reindex without domain', function(done) {
+    utils
+      .run('cs-index-documents',
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assert.deepEqual({ code:    result.code,
+                           message: result.output.stdout },
+                         { code:    1,
+                           message: 'You must specify the domain name.\n' },
+                         result.output.stderr);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+});
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index