cherry-pick Fix partial matches (#8047) (#8048)

Fix partial matches (#8047)

Support character escaping
This commit is contained in:
Andrew Henry 2025-04-24 09:57:06 -07:00 committed by GitHub
parent 9c9329d8b1
commit fffee68e9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View File

@ -466,21 +466,27 @@ class CouchObjectProvider {
let stringifiedKeys = JSON.stringify(keysToSearch); let stringifiedKeys = JSON.stringify(keysToSearch);
const url = `${this.url}/_design/${designDoc}/_view/${viewName}`; const url = `${this.url}/_design/${designDoc}/_view/${viewName}`;
const requestBody = {}; const requestBody = {};
let requestBodyString;
if (objectIdField === undefined) { if (objectIdField === undefined) {
requestBody.include_docs = true; requestBody.include_docs = true;
} }
if (limit !== undefined) {
requestBody.limit = limit;
}
if (startKey !== undefined && endKey !== undefined) { if (startKey !== undefined && endKey !== undefined) {
/* spell-checker: disable */ /* spell-checker: disable */
requestBody.startkey = startKey; requestBody.startkey = startKey;
requestBody.endkey = endKey; requestBody.endkey = endKey;
requestBodyString = JSON.stringify(requestBody);
requestBodyString = requestBodyString.replace('$START_KEY', startKey);
requestBodyString = requestBodyString.replace('$END_KEY', endKey);
/* spell-checker: enable */ /* spell-checker: enable */
} else { } else {
requestBody.keys = stringifiedKeys; requestBody.keys = stringifiedKeys;
} requestBodyString = JSON.stringify(requestBody);
if (limit !== undefined) {
requestBody.limit = limit;
} }
let objectModels = []; let objectModels = [];
@ -490,7 +496,7 @@ class CouchObjectProvider {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
signal: abortSignal, signal: abortSignal,
body: JSON.stringify(requestBody) body: requestBodyString
}); });
if (!response.ok) { if (!response.ok) {

View File

@ -94,7 +94,7 @@ class CouchSearchProvider {
designDoc: 'object_names', designDoc: 'object_names',
viewName: 'object_names', viewName: 'object_names',
startKey: preparedQuery, startKey: preparedQuery,
endKey: preparedQuery + '\\ufff0', endKey: preparedQuery + `\ufff0`,
objectIdField: 'value', objectIdField: 'value',
limit: 1000 limit: 1000
}, },