Skip to content

Commit ac120a8

Browse files
authored
Revert "Add Indexes to Schema API (#4240)"
This reverts commit d5c4324.
1 parent d5c4324 commit ac120a8

10 files changed

+76
-958
lines changed

spec/MongoSchemaCollectionAdapter.spec.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ describe('MongoSchemaCollection', () => {
2121
"create":{"*":true},
2222
"delete":{"*":true},
2323
"addField":{"*":true},
24-
},
25-
"indexes": {
26-
"name1":{"deviceToken":1}
2724
}
2825
},
2926
"installationId":"string",
@@ -69,10 +66,7 @@ describe('MongoSchemaCollection', () => {
6966
update: { '*': true },
7067
delete: { '*': true },
7168
addField: { '*': true },
72-
},
73-
indexes: {
74-
name1: {deviceToken: 1}
75-
},
69+
}
7670
});
7771
done();
7872
});

spec/ParseQuery.FullTextSearch.spec.js

Lines changed: 34 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ const fullTextHelper = () => {
3131
const request = {
3232
method: "POST",
3333
body: {
34-
subject: subjects[i],
35-
comment: subjects[i],
34+
subject: subjects[i]
3635
},
3736
path: "/1/classes/TestObject"
3837
};
@@ -281,83 +280,42 @@ describe('Parse.Query Full Text Search testing', () => {
281280
});
282281

283282
describe_only_db('mongo')('Parse.Query Full Text Search testing', () => {
284-
it('fullTextSearch: does not create text index if compound index exist', (done) => {
285-
fullTextHelper().then(() => {
286-
return databaseAdapter.dropAllIndexes('TestObject');
287-
}).then(() => {
288-
return databaseAdapter.getIndexes('TestObject');
289-
}).then((indexes) => {
290-
expect(indexes.length).toEqual(1);
291-
return databaseAdapter.createIndex('TestObject', {subject: 'text', comment: 'text'});
283+
it('fullTextSearch: $search, only one text index', (done) => {
284+
return reconfigureServer({
285+
appId: 'test',
286+
restAPIKey: 'test',
287+
publicServerURL: 'http://localhost:8378/1',
288+
databaseAdapter: new MongoStorageAdapter({ uri: mongoURI })
292289
}).then(() => {
293-
return databaseAdapter.getIndexes('TestObject');
294-
}).then((indexes) => {
295-
expect(indexes.length).toEqual(2);
296-
const where = {
297-
subject: {
298-
$text: {
299-
$search: {
300-
$term: 'coffee'
301-
}
302-
}
303-
}
304-
};
305290
return rp.post({
306-
url: 'http://localhost:8378/1/classes/TestObject',
307-
json: { where, '_method': 'GET' },
291+
url: 'http://localhost:8378/1/batch',
292+
body: {
293+
requests: [
294+
{
295+
method: "POST",
296+
body: {
297+
subject: "coffee is java"
298+
},
299+
path: "/1/classes/TestObject"
300+
},
301+
{
302+
method: "POST",
303+
body: {
304+
subject: "java is coffee"
305+
},
306+
path: "/1/classes/TestObject"
307+
}
308+
]
309+
},
310+
json: true,
308311
headers: {
309312
'X-Parse-Application-Id': 'test',
310313
'X-Parse-REST-API-Key': 'test'
311314
}
312315
});
313-
}).then((resp) => {
314-
expect(resp.results.length).toEqual(3);
315-
return databaseAdapter.getIndexes('TestObject');
316-
}).then((indexes) => {
317-
expect(indexes.length).toEqual(2);
318-
rp.get({
319-
url: 'http://localhost:8378/1/schemas/TestObject',
320-
headers: {
321-
'X-Parse-Application-Id': 'test',
322-
'X-Parse-Master-Key': 'test',
323-
},
324-
json: true,
325-
}, (error, response, body) => {
326-
expect(body.indexes._id_).toBeDefined();
327-
expect(body.indexes._id_._id).toEqual(1);
328-
expect(body.indexes.subject_text_comment_text).toBeDefined();
329-
expect(body.indexes.subject_text_comment_text.subject).toEqual('text');
330-
expect(body.indexes.subject_text_comment_text.comment).toEqual('text');
331-
done();
332-
});
333-
}).catch(done.fail);
334-
});
335-
336-
it('fullTextSearch: does not create text index if schema compound index exist', (done) => {
337-
fullTextHelper().then(() => {
338-
return databaseAdapter.dropAllIndexes('TestObject');
339316
}).then(() => {
340-
return databaseAdapter.getIndexes('TestObject');
341-
}).then((indexes) => {
342-
expect(indexes.length).toEqual(1);
343-
return rp.put({
344-
url: 'http://localhost:8378/1/schemas/TestObject',
345-
json: true,
346-
headers: {
347-
'X-Parse-Application-Id': 'test',
348-
'X-Parse-REST-API-Key': 'test',
349-
'X-Parse-Master-Key': 'test',
350-
},
351-
body: {
352-
indexes: {
353-
text_test: { subject: 'text', comment: 'text'},
354-
},
355-
},
356-
});
317+
return databaseAdapter.createIndex('TestObject', {random: 'text'});
357318
}).then(() => {
358-
return databaseAdapter.getIndexes('TestObject');
359-
}).then((indexes) => {
360-
expect(indexes.length).toEqual(2);
361319
const where = {
362320
subject: {
363321
$text: {
@@ -376,26 +334,12 @@ describe_only_db('mongo')('Parse.Query Full Text Search testing', () => {
376334
}
377335
});
378336
}).then((resp) => {
379-
expect(resp.results.length).toEqual(3);
380-
return databaseAdapter.getIndexes('TestObject');
381-
}).then((indexes) => {
382-
expect(indexes.length).toEqual(2);
383-
rp.get({
384-
url: 'http://localhost:8378/1/schemas/TestObject',
385-
headers: {
386-
'X-Parse-Application-Id': 'test',
387-
'X-Parse-Master-Key': 'test',
388-
},
389-
json: true,
390-
}, (error, response, body) => {
391-
expect(body.indexes._id_).toBeDefined();
392-
expect(body.indexes._id_._id).toEqual(1);
393-
expect(body.indexes.text_test).toBeDefined();
394-
expect(body.indexes.text_test.subject).toEqual('text');
395-
expect(body.indexes.text_test.comment).toEqual('text');
396-
done();
397-
});
398-
}).catch(done.fail);
337+
fail(`Should not be more than one text index: ${JSON.stringify(resp)}`);
338+
done();
339+
}).catch((err) => {
340+
expect(err.error.code).toEqual(Parse.Error.INTERNAL_SERVER_ERROR);
341+
done();
342+
});
399343
});
400344

401345
it('fullTextSearch: $diacriticSensitive - false', (done) => {

spec/Schema.spec.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ describe('SchemaController', () => {
274274
fooSixteen: {type: 'String'},
275275
fooEighteen: {type: 'String'},
276276
fooNineteen: {type: 'String'},
277-
}, levelPermissions, {}, config.database))
277+
}, levelPermissions, config.database))
278278
.then(actualSchema => {
279279
const expectedSchema = {
280280
className: 'NewClass',
@@ -304,9 +304,6 @@ describe('SchemaController', () => {
304304
fooNineteen: {type: 'String'},
305305
},
306306
classLevelPermissions: { ...levelPermissions },
307-
indexes: {
308-
_id_: { _id: 1 }
309-
}
310307
};
311308

312309
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);

0 commit comments

Comments
 (0)