[Groonga-commit] groonga/gcs [master] Update import script to use gcs commands

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Aug 28 19:46:17 JST 2012


YUKI Hiroshi	2012-08-28 19:46:17 +0900 (Tue, 28 Aug 2012)

  New Revision: 23719ee832cd714d8d0707d0701841804f9f9fdb
  https://github.com/groonga/gcs/commit/23719ee832cd714d8d0707d0701841804f9f9fdb

  Log:
    Update import script to use gcs commands

  Copied files:
    bin/gcs-import-examples-http
      (from bin/gcs-import-examples)
  Modified files:
    bin/gcs-import-examples

  Modified: bin/gcs-import-examples (+26 -53)
===================================================================
--- bin/gcs-import-examples    2012-08-28 19:06:10 +0900 (8ed63ea)
+++ bin/gcs-import-examples    2012-08-28 19:46:17 +0900 (5ad4a75)
@@ -13,27 +13,6 @@ This script setup an example domain and import data into the domain.
 
 EOT
 
-echo "Checking prerequisites..."
-echo
-
-printf "* gcs running..."
-curl --silent "http://localhost:7575" > /dev/null
-if [ $? -eq 0 ]
-then
-  echo " "$GREEN"OK"$RESET
-else
-  echo " "$RED"not running"$RESET
-  printf $YELLOW
-cat <<"EOT"
-
-You need to run gcs on port 7575. Just run gcs command without any options on another terminal.
-
-  $ gcs
-
-EOT
-  printf $RESET
-fi
-
 cat <<EOT
 
 NOTICE:
@@ -46,59 +25,53 @@ EOT
 read enter
 
 
+base_path=
+bin_path=
+for path_prefix in "`dirname $0`/.." "`npm root`/gcs" "`npm -g root`/gcs"
+do
+  base_path="$path_prefix"
+  bin_path="$base_path/bin"
+  if [ -d "$base_path" ]; then
+    break
+  fi
+done
+
 
 echo "==== Deleting 'example' domain (if exists)"
-curl -s "http://localhost:7575/?DomainName=example&Action=DeleteDomain&Version=2011-02-01" > /dev/null
+$bin_path/gcs-delete-domain --domain-name example --force
 echo
 
 echo "==== Creating 'example' domain"
 
-create_domain_result=`curl -s "http://localhost:7575/?DomainName=example&Action=CreateDomain&Version=2011-02-01"`
-echo $create_domain_result
+$bin_path/gcs-create-domain --domain-name example
+
+describe_domain_result=`$bin_path/gcs-describe-domain --domain-name example`
+echo $describe_domain_result
 echo
 echo
 
-case $(uname) in
-  Darwin|*BSD)
-    sed="sed -E"
-    ;;
-  *)
-    sed="sed -r"
-    ;;
-esac
-
-documents_endpoint=`echo "$create_domain_result" | $sed -e "s/.+<DocService><Endpoint>//" | $sed -e "s/<.+//"`
-search_endpoint=`echo "$create_domain_result" | $sed -e "s/.+<SearchService><Endpoint>//" | $sed -e "s/<.+//"`
-
 echo "==== Adding index fields"
 echo "== Creating 'name' field"
-curl -s "http://localhost:7575/?Action=DefineIndexField&DomainName=example&IndexField.IndexFieldName=name&IndexField.IndexFieldType=text&TextOptions.ResultEnabled=true&TextOption.FacetEnabled=true&Version=2011-02-01"
+$bin_path/gcs-configure-fields --domain-name example --name name --type text --option result
+$bin_path/gcs-configure-fields --domain-name example --name name --type text --option facet
 echo
 echo "== Creating 'address' field"
-curl -s "http://localhost:7575/?Action=DefineIndexField&DomainName=example&IndexField.IndexFieldName=address&IndexField.IndexFieldType=text&TextOptions.ResultEnabled=true&TextOption.FacetEnabled=true&Version=2011-02-01"
+$bin_path/gcs-configure-fields --domain-name example --name address --type text --option result
+$bin_path/gcs-configure-fields --domain-name example --name address --type text --option facet
 echo
 echo "== Creating 'email_address' field"
-curl -s "http://localhost:7575/?Action=DefineIndexField&DomainName=example&IndexField.IndexFieldName=email_address&IndexField.IndexFieldType=text&TextOptions.ResultEnabled=true&TextOption.FacetEnabled=true&Version=2011-02-01"
+$bin_path/gcs-configure-fields --domain-name example --name email_address --type text --option result
+$bin_path/gcs-configure-fields --domain-name example --name email_address --type text --option facet
 echo
 echo "== Creating 'products' field"
-curl -s "http://localhost:7575/?Action=DefineIndexField&DomainName=example&IndexField.IndexFieldName=products&IndexField.IndexFieldType=literal&LiteralOptions.SearchEnabled=true&LiteralOptions.ResultEnabled=true&LiteralOptions.FacetEnabled=true&Version=2011-02-01"
+$bin_path/gcs-configure-fields --domain-name example --name products --type literal --option search
+$bin_path/gcs-configure-fields --domain-name example --name products --type literal --option result
+$bin_path/gcs-configure-fields --domain-name example --name products --type literal --option facet
 echo
 
 echo
 echo "==== Indexing data"
-sdf_path=
-sdf_base_path=examples/example.sdf.json
-for sdf_path_prefix in "`dirname $0`/.." "`npm root`/gcs" "`npm -g root`/gcs"
-do
-    sdf_path="$sdf_path_prefix/$sdf_base_path"
-    if [ -f "$sdf_path" ]; then
-	break
-    else
-	sdf_path=
-    fi
-done
-
-curl -X POST --upload-file $sdf_path --header "Content-Type: application/json" http://$documents_endpoint/2011-02-01/documents/batch
+$bin_path/gcs-post-sdf --domain-name example --source $base_path/examples/example.sdf.json
 echo
 
 echo

  Copied: bin/gcs-import-examples-http (+0 -0) 100%
===================================================================
-------------- next part --------------
HTML����������������������������...
Download 



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