[Groonga-commit] groonga/gcs [master] Add example importer. Closes #21.

Back to archive index

null+****@clear***** null+****@clear*****
2012年 6月 28日 (木) 13:38:29 JST


Yoji SHIDARA	2012-06-28 13:38:29 +0900 (Thu, 28 Jun 2012)

  New Revision: 295f3feb3c5f81fa7588a52b7736c50159522f5a
  https://github.com/groonga/gcs/commit/295f3feb3c5f81fa7588a52b7736c50159522f5a

  Log:
    Add example importer. Closes #21.

  Added files:
    bin/gcs-import-examples
    examples/example.sdf.json

  Added: bin/gcs-import-examples (+67 -0) 100755
===================================================================
--- /dev/null
+++ bin/gcs-import-examples    2012-06-28 13:38:29 +0900 (73afa02)
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+cat <<EOT
+Groonga CloudSearch example data importer
+-----------------------------------------
+
+This script setup an example domain and import data into the domain.
+
+Prerequsites:
+
+1) You need to direct 'doc-example-example.localhost' and 'search-example-example.localhost' to 127.0.0.1 before trying this example. To do so:
+
+$ sudo sh -c 'echo "127.0.0.1 doc-companies-example.localhost" >> /etc/hosts'
+$ sudo sh -c 'echo "127.0.0.1 search-companies-example.localhost" >> /etc/hosts'
+
+2) You need to run gcs on port 3000. Just run gcs command without any options.
+
+$ gcs
+
+NOTICE:
+
+If you have data in the domain whose name is 'example', it will be updated.
+
+
+EOT
+
+echo "Hit enter to continue. Ctrl-C to break."
+read
+
+
+echo "==== Creating 'example' domain"
+
+curl -s "http://127.0.0.1:3000/?DomainName=example&Action=CreateDomain&Version=2011-02-01"
+echo
+echo
+
+echo "==== Adding index fields"
+echo "== Creating 'name' field"
+curl -s "http://127.0.0.1:3000/?Action=DefineIndexField&DomainName=example&IndexField.IndexFieldName=name&Version=2011-02-01"
+echo
+echo "== Creating 'address' field"
+curl -s "http://127.0.0.1:3000/?Action=DefineIndexField&DomainName=example&IndexField.IndexFieldName=address&Version=2011-02-01"
+echo
+echo "== Creating 'email_address' field"
+curl -s "http://127.0.0.1:3000/?Action=DefineIndexField&DomainName=example&IndexField.IndexFieldName=email_address&Version=2011-02-01"
+echo
+
+echo
+echo "==== Indexing data"
+sdf_path=$(cd $(dirname $0);pwd)/../examples/example.sdf.json
+
+curl -X POST --upload-file $sdf_path --header "Content-Type: application/json" -H "Host: doc-example-example.localhost" http://127.0.0.1:3000/2011-02-01/documents/batch
+echo
+
+echo
+echo "Done."
+
+cat <<EOT
+
+Now you can try searching by
+
+$ curl -H "Host: search-example-example.localhost" "http://127.0.0.1:3000/2011-02-01/search?q=Tokyo"
+
+or, open
+http://127.0.0.1:3000
+for web dashboard.
+EOT

  Added: examples/example.sdf.json (+105 -0) 100644
===================================================================
--- /dev/null
+++ examples/example.sdf.json    2012-06-28 13:38:29 +0900 (46c8756)
@@ -0,0 +1,105 @@
+[
+  {
+    "type": "add",
+    "id": "id1",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "Brazil",
+      "address": "Shibuya, Tokyo, Japan",
+      "email_address": "info****@razil*****"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id2",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "Enishi Tech Inc.",
+      "address": "Sapporo, Hokkaido, Japan",
+      "email_address": "info****@enish*****"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id3",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "ClearCode Inc.",
+      "address": "Hongo, Tokyo, Japan",
+      "email_address": "info****@clear*****"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id4",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "Anaheim Electronics",
+      "address": "Granada, Moon"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id5",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "Shinsei Industry",
+      "address": "Earth"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id6",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "Omni Consumer Products",
+      "address": "Detroit and Delta City, Michigan, United States"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id7",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "Capsule Corporation",
+      "address": "West City"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id8",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "Stark Industries",
+      "address": "United States"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id9",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "Umbrella Corporation",
+      "address": "Tokyo, Japan"
+    }
+  },
+  {
+    "type": "add",
+    "id": "id10",
+    "version": 1,
+    "lang": "en",
+    "fields": {
+      "name": "U.S. Robots and Mechanical Men",
+      "address": "New York, United States"
+    }
+  }
+]
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



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