title: Spring Data Mongodb Near Query not works
body: <p>I would like to find the nearest shop. So I wrote this code: </p>
  
  <pre><code>public class ShopRepositoryImpl extends GenericRepositoryImpl&lt;ShopEntity, String&gt; implements ShopRepositoryCustom {
  
      @Autowired
      protected MongoTemplate template;
  
      @Override
      public GeoResult&lt;ShopEntity&gt; findNearest(Point location) {
          List&lt;GeoResult&lt;ShopEntity&gt;&gt; result = template.geoNear(
                  NearQuery.near(location).maxDistance(new Distance(70, Metrics.KILOMETERS))
                          .query(new Query(Criteria.where("location")).limit(1)),
                  ShopEntity.class).getContent();
          if (result.isEmpty())  {
              return null;
          } else {
              return result.get(0);
          }
      }
  }
  </code></pre>
  
  <p>In tomcat console there is : </p>
  
  <pre><code>2016-01-17 12:13:26.151  WARN 645 --- [nio-8080-exec-2]     o.s.data.mongodb.core.MongoTemplate      : Command execution of 
  { "geoNear" : "shop" , "query" : { "location" : { }} , "maxDistance" : 0.010974991600211786 , "distanceMultiplier" : 6378.137 , "num" : 1 , "near" : [ 48.8703939 , 2.0] , "spherical" : true} 
  failed: no geo indices for geoNear
  </code></pre>
  
  <p>And I tried this : </p>
  
  <pre><code>public interface ShopRepository extends GenericRepository&lt;ShopEntity, String&gt;, ShopRepositoryCustom {
      GeoResults&lt;ShopEntity&gt; findByLocationNear(Point location, Distance distance);
  }
  </code></pre>
  
  <p>No result</p>
  
  <p>In my database I have one element : </p>
  
  <pre><code>  {
      "name": "A shop",
      "street": "149 Rue Montmartre",
      "city": "Paris",
      "zip": "75002",
      "country": "France",
      "location": {
        "x": 48.8703937,
        "y": 2.3422999
      }
    }
  </code></pre>