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

View File

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