Set the minDistance in geonear - mongodb

I'm trying to have a geo-pagination system.
I refeer to this article
Blog article from mongoDB
My problem is that I'm using doctrine MongoDB and i don't seem to find how to set minDistance field in Doctrine MongoDB
My Mongo version is 2.4.8

Support for this was not implemented in Doctrine MongoDB, but I've implemented it in PR #171, which is now in the 1.2.x-dev branch (we don't yet have a 1.2.0 release). You can look at the documentation blocks or unit tests in that PR for insight into how to use it, but I modeled it after maxDistance().
I should mention that in 1.1.x of Doctrine MongoDB, you didn't actually need the builder method available to inject the minDistance option into geoNear. If you look at this code in Query.php, you'll see that we merge options from the builder atop $options, which ultimately comes from Query's constructor. Keep this in mind should you need to pass options to other commands when there is not a pre-existing builder method.
Lastly, you mentioned that you're using MongoDB 2.4.8. Note that MongoDB 2.4.x does not support this option (for geoNear) or query operator (for $near and $nearSphere). It was implemented in SERVER-9395 (this commit) and first appeared in 2.5.1. You'll also find it in 2.6.0, of course.

Related

Can I do pagination with spring-data-jdbc?

I would like to use PagingAndSortingRepository with spring-data-jdbc but it not seem to work. It's only available with JPA ?
I tried to use PagingAndSortingRepository and use the findAll(Pageable pageable).
But I actually get a "No query specified on findAll"
2020 Update
Support for PagingRepositories was introduced at version 2.0.0.M3 (2020-02-12).
Spring Data JDBC Changelog
PagingAndSortingRepository is supported since version 2.0 M3
That version wasn't available when this question was asked.
Original answer
Yes, you are right, pagination isn't ready yet.
There is actually a PR that will create infrastructure for that but it won't enable the feature yet. For that you should watch https://jira.spring.io/browse/DATAJDBC-101.

Generating schema with waterline-orientdb

In many of the previous Waterline databases that I've hacked around with, you could create a Waterline/Sails model using the "generic" syntax specified by Waterline/Sails and things would just work. When I started using OrientDB and Waterline-OrientDB there appears to be an issue whereby I have to define my full schema in OrientDB before I am able to persist anything. Is this a requirement for using Waterline-OrientDB or is there something not configured properly about my OrientDB setup which is forcing the schema to be defined first.
If the creation is necessary, how should one model the edges in the OrientDB database and in SailsJS to ensure that the Sails/Waterline ORM will be able to persist properly. I assumed that it would "just work", but throughout the waterline-orientdb documentation are references to calls for creating edges and such. That seems to be a crucial feature from the documentation - what do you HAVE to define, and what can you get away with not defining for SailsJS model objects.
No waterline model definition or config have been provided, so it's hard to pinpoint what the exact issue is. One possible cause is that migrate is set to 'safe' in the config. waterline-orientdb follows the migratable interface and as such it will only create classes when migrate: 'drop' or migrate: 'alter' (waterline deems this as experimental) or migrate: 'create' (in waterline master branch, not released yet). More about setting the migrate options on Sails.js docs - model settings.
Regarding the second paragraph, waterline-orientdb complies 100% to the waterline specification and it passes all API integration tests for Waterline adapters (results). Edges are modelled as normal waterline many-to-many associations. The waterline-orientdb documentation follows the example of other adapters as it mostly documents things that are particular to waterline-orientdb, namely extensions made. In other words waterline-orientdb can be used just like any other adapter and these extensions are just to help with specific OrientDB operations.
Let me know if this doesn't fix your issue and feel free to provide examples, I'll look into them.

Mongo C# Driver OData issue "Where with predicate after a project is not supported"

Request: /api/person?$filter Name eq 'John' with server backed up method that
return repo.GetAll().Select(o => Mapper.Map<>PersonDTO>(o));
Only the $filter requests error out with "Where with predicate after a project is not supported" but $top / $skip / $orderby work fine. My guess is, Mongo C# has a bug while generating the query & projects before applying the filter. Instead it should apply filter first and then project. I am using OData 5.2.0-rc1 and Mongo C# driver is 1.7.
Any inputs are much appreciated. Thanks...
That is a limitation in the current implementation of Linq. We are working to correct that with this ticket: https://jira.mongodb.org/browse/CSHARP-601.
However, I'd encourage you to figure out what you are actually attempting to do. Projecting prior to a filter could mean you are filtering on computed expressions, such as adding 2 columns together. MongoDB queries do not support this type of behavior, which is why this is currently disallowed by our linq provider. Aggregation framework allows this to a point, but there are a different set of limitations imposed by the Aggregation framework.
In your particular case, what you are wanting us to do is impossible. You are asking us to know how to create a MongoDB query based on an AutoMapper generated object. This simply impossible unless we (at runtime) read the AutoMapper mapping and apply it to our internal class models.

Yii Gii with MongoDB

Could anyone please tell me how MongoDB can be used with YII?
How can we create controller and model functions using Gii if the database used is MongoDB?
I've used YiiMongoDBSuite (YMDS), which has some very rough support for Gii. You can generate starter classes, but given that MongoDB does not have a fixed schema you will need to edit the model to make them useful. There is an odd kludge that lets you generate MongoDB models from a SQL table, but this seems more effort than it's worth.
YMDS' EMongoDocument class extends the standard Yii CModel class, so this is a useful base if you want to build apps with CRUDS.
The unfortunate caveat is that YMDS is no longer maintained by the original author, and there are a few community forks to chose between.
The way of creating controllers is same as usual but you have to use an extension to talk to mongoDB from Yii ,
You need to use direct Mongo suite of yii . It is an extension which has a collection of components for the mongoDB .

Mongo Grouping doesn't happen at DB level and doesn't use Mongo Aggregation Framework

Mongo Grouping doesn't happen at DB level and doesn't use Mongo Aggregation Framework with the following code. Any idea why? I have to create CommandDocument and RunCommand, then only it uses the aggregation framework.
public IEnumerable<IGrouping<TKey, T>> GetItemsByQuery<TKey>(IMongoQuery query, FieldsBuilder fieldsBuilder, Func<T, TKey> groupbyKey)
{
var mongoCursor = collection.FindAs<T>(query);
mongoCursor.SetFields(fieldsBuilder);
return mongoCursor.GroupBy(groupbyKey);
}
1) The aggregation framework is only support in unstable releases of MongoDB version 2.1 and higher. It will be formally supported in server 2.2. So, unless you are running server 2.1 or greater, you won't get this feature server side.
2) The driver does not yet support the aggregation framework. You can build the aggregation manually and use db.RunCommand to execute it.
3) You are calling the IEnumerable extension method off of a MongoCursor. MongoCursor does have any idea of what you are asking it to do and therefore, the grouping will happen clientside. There is a method on the collection called Group, but you'll need to write some javascript to execute that.
All in all, we don't have a great aggregation story yet. In server 2.2, that will change, but it isn't here yet.