diff options
-rw-r--r-- | package.json | 3 | ||||
-rw-r--r-- | src/debug/Test.tsx | 19 | ||||
-rw-r--r-- | src/server/Search.ts | 25 | ||||
-rw-r--r-- | src/server/index.ts | 3 |
4 files changed, 48 insertions, 2 deletions
diff --git a/package.json b/package.json index fd794d062..3393eacc6 100644 --- a/package.json +++ b/package.json @@ -167,9 +167,10 @@ "serializr": "^1.5.1", "socket.io": "^2.2.0", "socket.io-client": "^2.2.0", + "solr-node": "^1.1.3", "typescript-collections": "^1.3.2", "url-loader": "^1.1.2", "uuid": "^3.3.2", "xoauth2": "^1.2.0" } -}
\ No newline at end of file +} diff --git a/src/debug/Test.tsx b/src/debug/Test.tsx index 47cfac2c1..7d72a1ba0 100644 --- a/src/debug/Test.tsx +++ b/src/debug/Test.tsx @@ -3,6 +3,9 @@ import * as ReactDOM from 'react-dom'; import { serialize, deserialize, map } from 'serializr'; import { URLField, Doc, createSchema, makeInterface, makeStrictInterface, List, ListSpec } from '../fields/NewDoc'; import { SerializationHelper } from '../client/util/SerializationHelper'; +import { Search } from '../server/Search'; +import { restProperty } from 'babel-types'; +import * as rp from 'request-promise'; const schema1 = createSchema({ hello: "number", @@ -76,8 +79,22 @@ class Test extends React.Component { // console.log(SerializationHelper.Serialize(l)); } + onEnter = async (e: any) => { + var key = e.keyCode || e.which; + if (key === 13) { + var query = e.target.value; + await rp.get('http://localhost:1050/search', { + qs: { + query + } + }); + } + } + render() { - return <button onClick={this.onClick}>Click me</button>; + return <div><button onClick={this.onClick}>Click me</button> + <input onKeyPress={this.onEnter}></input> + </div>; } } diff --git a/src/server/Search.ts b/src/server/Search.ts index 9e462f0ae..4911edd1d 100644 --- a/src/server/Search.ts +++ b/src/server/Search.ts @@ -5,6 +5,31 @@ import { thisExpression } from 'babel-types'; export class Search { public static Instance = new Search(); private url = 'http://localhost:8983/solr/'; + private client: any; + + constructor() { + console.log("Search Instantiated!"); + var SolrNode = require('solr-node'); + this.client = new SolrNode({ + host: 'localhost', + port: '8983', + core: 'dash', + protocol: 'http' + }); + var strQuery = this.client.query().q('text:test'); + + console.log(strQuery); + + // Search documents using strQuery + // client.search(strQuery, (err: any, result: any) => { + // if (err) { + // console.log(err); + // return; + // } + // console.log('Response:', result.response); + // }); + } + public async updateDocument(document: any) { console.log("UPDATE: ", JSON.stringify(document)); diff --git a/src/server/index.ts b/src/server/index.ts index f90724152..f2bcd3f00 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -122,11 +122,14 @@ app.get("/pull", (req, res) => res.redirect("/"); })); +// SEARCH + // GETTERS app.get("/search", async (req, res) => { let query = req.query.query || "hello"; let results = await Search.Instance.search(query); + console.log(results); res.send(results); }); |