* @see org.springframework.data.repository.core.support.QueryCreationListener#onCreation(org.springframework.data.repository.query.RepositoryQuery)
*/
public void onCreation(PartTreeMongoQuery query) {
PartTree tree = query.getTree();
Index index = new Index();
index.named(query.getQueryMethod().getName());
Sort sort = tree.getSort();
for (Part part : tree.getParts()) {
if (GEOSPATIAL_TYPES.contains(part.getType())) {
return;
}
String property = part.getProperty().toDotPath();
Direction order = toDirection(sort, property);
index.on(property, order);
}
// Add fixed sorting criteria to index
if (sort != null) {
for (Sort.Order order : sort) {
index.on(order.getProperty(), order.getDirection());
}
}
MongoEntityMetadata<?> metadata = query.getQueryMethod().getEntityInformation();
operations.indexOps(metadata.getCollectionName()).ensureIndex(index);