[748a59]: / nih-ct-protocol-ui / src / app / predict.service.ts

Download this file

52 lines (39 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { catchError, map, tap } from 'rxjs/operators';
import { Result } from './result';
@Injectable({
providedIn: 'root'
})
export class PredictService {
//headers: new HttpHeaders({ 'Content-Type': 'application/json' })
constructor(private http: HttpClient) { }
predict(type:string, criteria:string): Observable<any>{
let m = {
"min_score": 0.1,
"query": {
"match": {
"value": "xsxsx"
}
},
"highlight" : {
"pre_tags" : ["<mark>"],
"post_tags" : ["</mark>"],
"fields" : {
"value" : {}
}
}
};
m.query.match.value = criteria;
//return this.http.post<any>(this.url,m,this.httpOptions).pipe(
// catchError(this.handleError('predict', new Result()))
// );
// }
private handleError<T> (operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
console.error(error);
return of(result as T);
};
}
};