1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.SearchRequest = exports.SearchScanConsistency = exports.HighlightStyle = exports.SearchResult = exports.SearchRow = exports.SearchMetaData = void 0;
|
4 | const errors_1 = require("./errors");
|
5 | const searchquery_1 = require("./searchquery");
|
6 | const vectorsearch_1 = require("./vectorsearch");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | class SearchMetaData {
|
15 | }
|
16 | exports.SearchMetaData = SearchMetaData;
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | class SearchRow {
|
25 | }
|
26 | exports.SearchRow = SearchRow;
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | class SearchResult {
|
33 | |
34 |
|
35 |
|
36 | constructor(data) {
|
37 | this.rows = data.rows;
|
38 | this.meta = data.meta;
|
39 | }
|
40 | }
|
41 | exports.SearchResult = SearchResult;
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | var HighlightStyle;
|
48 | (function (HighlightStyle) {
|
49 | |
50 |
|
51 |
|
52 | HighlightStyle["HTML"] = "html";
|
53 | |
54 |
|
55 |
|
56 | HighlightStyle["ANSI"] = "ansi";
|
57 | })(HighlightStyle || (exports.HighlightStyle = HighlightStyle = {}));
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | var SearchScanConsistency;
|
65 | (function (SearchScanConsistency) {
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 | SearchScanConsistency["NotBounded"] = "not_bounded";
|
72 | })(SearchScanConsistency || (exports.SearchScanConsistency = SearchScanConsistency = {}));
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | class SearchRequest {
|
79 | constructor(query) {
|
80 | if (query instanceof searchquery_1.SearchQuery) {
|
81 | this._searchQuery = query;
|
82 | }
|
83 | else if (query instanceof vectorsearch_1.VectorSearch) {
|
84 | this._vectorSearch = query;
|
85 | }
|
86 | else {
|
87 | throw new errors_1.InvalidArgumentError(new Error('Must provide either a SearchQuery or VectorSearch when creating SearchRequest.'));
|
88 | }
|
89 | }
|
90 | |
91 |
|
92 |
|
93 | get searchQuery() {
|
94 | return this._searchQuery;
|
95 | }
|
96 | |
97 |
|
98 |
|
99 | get vectorSearch() {
|
100 | return this._vectorSearch;
|
101 | }
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 | withSearchQuery(query) {
|
108 | if (!(query instanceof searchquery_1.SearchQuery)) {
|
109 | throw new errors_1.InvalidArgumentError(new Error('Must provide a SearchQuery.'));
|
110 | }
|
111 | if (this._searchQuery) {
|
112 | throw new errors_1.InvalidArgumentError(new Error('Request already has a SearchQuery.'));
|
113 | }
|
114 | this._searchQuery = query;
|
115 | return this;
|
116 | }
|
117 | |
118 |
|
119 |
|
120 |
|
121 |
|
122 | withVectorSearch(search) {
|
123 | if (!(search instanceof vectorsearch_1.VectorSearch)) {
|
124 | throw new errors_1.InvalidArgumentError(new Error('Must provide a VectorSearch.'));
|
125 | }
|
126 | if (this._vectorSearch) {
|
127 | throw new errors_1.InvalidArgumentError(new Error('Request already has a VectorSearch.'));
|
128 | }
|
129 | this._vectorSearch = search;
|
130 | return this;
|
131 | }
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 | static create(query) {
|
138 | return new SearchRequest(query);
|
139 | }
|
140 | }
|
141 | exports.SearchRequest = SearchRequest;
|