aboutsummaryrefslogtreecommitdiff
path: root/src/server/Search.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Search.ts')
-rw-r--r--src/server/Search.ts37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/server/Search.ts b/src/server/Search.ts
index 8ae996e9e..6e7883bc9 100644
--- a/src/server/Search.ts
+++ b/src/server/Search.ts
@@ -1,14 +1,41 @@
import * as rp from 'request-promise';
import { Database } from './database';
+import { thisExpression } from 'babel-types';
export class Search {
public static Instance = new Search();
private url = 'http://localhost:8983/solr/';
+ private client: any;
- public updateDocument(document: any): rp.RequestPromise {
- return rp.post(this.url + "dash/update/json/docs", {
+ 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));
+ return rp.post(this.url + "dash/update", {
headers: { 'content-type': 'application/json' },
- body: JSON.stringify(document)
+ body: JSON.stringify([document])
});
}
@@ -22,9 +49,7 @@ export class Search {
}));
const fields = searchResults.response.docs;
const ids = fields.map((field: any) => field.id);
- const docs = await Database.Instance.searchQuery(ids);
- const docIds = docs.map((doc: any) => doc._id);
- return docIds;
+ return ids;
}
public async clear() {