Beginnings of fulltext search form
Beginnings of fulltext search form


Former-commit-id: 2138a5cc3869bab7a9e67ddae3ad040d77577bbf

--- a/.gitmodules
+++ b/.gitmodules
@@ -13,4 +13,7 @@
 [submodule "javascripts/flot"]
 	path = javascripts/flot
 	url = https://github.com/paradoxxxzero/flot.git
+[submodule "lib/Requests"]
+	path = lib/Requests
+	url = https://github.com/rmccue/Requests.git
 

--- /dev/null
+++ b/couchdb/couchdb-lucene-run.bat.txt
@@ -1,1 +1,18 @@
+@echo off
 
+set CLASSPATH="../conf;"
+Echo Cleared classpath
+
+set JAVA_OPTS="-server -Xmx1g"
+Echo set Java Opts %JAVA_OPTS%
+
+set CLASS=com.github.rnewson.couchdb.lucene.Main
+Echo set couchdb-lucene class %CLASS%
+
+setlocal ENABLEDELAYEDEXPANSION
+if defined CLASSPATH (set CLASSPATH=%CLASSPATH%;.) else (set CLASSPATH=.)
+FOR /R ..\lib %%G IN (*.jar) DO set CLASSPATH=!CLASSPATH!;%%G
+Echo The Classpath definition is %CLASSPATH%
+
+java "%JAVA_OPTS%" -cp %CLASSPATH% %CLASS%
+

directory:a/couchdb/settee -> directory:b/couchdb/settee
--- a/couchdb/settee
+++ b/couchdb/settee

--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -11,7 +11,9 @@
 
 include_once ('couchdb.inc.php');
 include_once ('template.inc.php');
+require_once $basePath.'lib/Requests/library/Requests.php';
 
+Requests::register_autoloader();
 # Convert a stdClass to an Array. http://www.php.net/manual/en/language.types.object.php#102735
 
 function object_to_array(stdClass $Class) {

--- a/include/couchdb.inc.php
+++ b/include/couchdb.inc.php
@@ -3,6 +3,28 @@
 include $basePath . "schemas/schemas.inc.php";
 
 require ($basePath . 'couchdb/settee/src/settee.php');
+
+function createDocumentsDesignDoc() {
+    /*"views": {
+       "web_server": {
+           "map": "function(doc) {\n  emit(doc.web_server, 1);\n}",
+           "reduce": "function (key, values, rereduce) {\n    return sum(values);\n}"
+       },
+       "byAgency": {
+           "map": "function(doc) {\n  emit(doc.agencyID, 1);\n}",
+           "reduce": "function (key, values, rereduce) {\n    return sum(values);\n}"
+       },
+       "byURL": {
+           "map": "function(doc) {\n  emit(doc.url, doc);\n}"
+       },
+       "agency": {
+           "map": "function(doc) {\n  emit(doc.agencyID, doc);\n}"
+       },
+       "byWebServer": {
+           "map": "function(doc) {\n  emit(doc.web_server, doc);\n}"
+       }
+   }*/
+}
 
 function createAgencyDesignDoc() {
     global $db;
@@ -120,16 +142,16 @@
 }
 
 if (php_uname('n') == "vanille") {
-
-    $server = new SetteeServer('http://192.168.178.21:5984');
+$serverAddr = 'http://192.168.178.21:5984/';
+   
 } else
 if (php_uname('n') == "KYUUBEY") {
 
-    $server = new SetteeServer('http://192.168.1.148:5984');
+    $serverAddr = 'http://192.168.1.148:5984/';
 } else {
-    $server = new SetteeServer('http://127.0.0.1:5984');
+    $serverAddr = 'http://127.0.0.1:5984/';
 }
-
+ $server = new SetteeServer($serverAddr);
 function setteErrorHandler($e) {
     echo $e->getMessage() . "<br>" . PHP_EOL;
 }

directory:b/lib/Requests (new)
--- /dev/null
+++ b/lib/Requests

file:b/search.php (new)
--- /dev/null
+++ b/search.php
@@ -1,1 +1,25 @@
+<?php
+include_once('include/common.inc.php');
+include_header();
+?>
+<div class="foundation-header">
+    <h1><a href="search.php">Search</a></h1>
+</div>
+<form>
+    <input type="text" name="q" value="<?php if (isset($_REQUEST['q']))echo $_REQUEST['q'];?>"/>
+    <input type="submit"/>
+</form>
 
+<?php
+if (isset($_REQUEST['q'])) {
+    $request = Requests::get($serverAddr."disclosr-documents/_fti/_design/lucene/by_all?include_docs=true&q=".$_REQUEST['q']);
+    $results = json_decode($request->body);
+    $db = $server->get_db('disclosr-documents');
+    foreach ($results->rows as $result) {
+        //print_r($result);
+         //$row = $db->get($result->id);
+        echo $result->doc->_id." ".$result->doc->url."<br>".PHP_EOL;
+    }
+}
+include_footer();
+?>