Skip to content

Commit 4b2a63a

Browse files
CSHARP-3045: Deprecate geoHaystack and geoSearch.
1 parent 03f6627 commit 4b2a63a

File tree

15 files changed

+60
-2
lines changed

15 files changed

+60
-2
lines changed

src/MongoDB.Driver.Core/Core/Operations/CreateIndexRequest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public int? Bits
100100
/// <value>
101101
/// The size of the bucket for geo haystack indexes.
102102
/// </value>
103+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
103104
public double? BucketSize
104105
{
105106
get { return _bucketSize; }

src/MongoDB.Driver.Core/Core/Operations/GeoSearchOperation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace MongoDB.Driver.Core.Operations
3030
/// Represents the geoSearch command.
3131
/// </summary>
3232
/// <typeparam name="TResult">The type of the result.</typeparam>
33+
[Obsolete("The geoSearch command was deprecated in server version 4.4.")]
3334
public sealed class GeoSearchOperation<TResult> : IReadOperation<TResult>
3435
{
3536
private readonly CollectionNamespace _collectionNamespace;

src/MongoDB.Driver.Legacy/Builders/IndexKeysBuilder.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public static IndexKeysBuilder GeoSpatial(string name)
6666
/// </summary>
6767
/// <param name="name">The key name.</param>
6868
/// <returns>The builder (so method calls can be chained).</returns>
69+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
6970
public static IndexKeysBuilder GeoSpatialHaystack(string name)
7071
{
7172
return new IndexKeysBuilder().GeoSpatialHaystack(name);
@@ -77,6 +78,7 @@ public static IndexKeysBuilder GeoSpatialHaystack(string name)
7778
/// <param name="name">The key name.</param>
7879
/// <param name="additionalName">The name of an additional field to index.</param>
7980
/// <returns>The builder (so method calls can be chained).</returns>
81+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
8082
public static IndexKeysBuilder GeoSpatialHaystack(string name, string additionalName)
8183
{
8284
return new IndexKeysBuilder().GeoSpatialHaystack(name, additionalName);
@@ -198,6 +200,7 @@ public IndexKeysBuilder GeoSpatial(string name)
198200
/// </summary>
199201
/// <param name="name">The key name.</param>
200202
/// <returns>The builder (so method calls can be chained).</returns>
203+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
201204
public IndexKeysBuilder GeoSpatialHaystack(string name)
202205
{
203206
return GeoSpatialHaystack(name, null);
@@ -209,6 +212,7 @@ public IndexKeysBuilder GeoSpatialHaystack(string name)
209212
/// <param name="name">The key name.</param>
210213
/// <param name="additionalName">The name of an additional field to index.</param>
211214
/// <returns>The builder (so method calls can be chained).</returns>
215+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
212216
public IndexKeysBuilder GeoSpatialHaystack(string name, string additionalName)
213217
{
214218
_document.Add(name, "geoHaystack");
@@ -355,6 +359,7 @@ public static IndexKeysBuilder<TDocument> GeoSpatial<TMember>(Expression<Func<TD
355359
/// <returns>
356360
/// The builder (so method calls can be chained).
357361
/// </returns>
362+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
358363
public static IndexKeysBuilder<TDocument> GeoSpatialHaystack<TMember>(Expression<Func<TDocument, TMember>> memberExpression)
359364
{
360365
return new IndexKeysBuilder<TDocument>().GeoSpatialHaystack(memberExpression);
@@ -370,6 +375,7 @@ public static IndexKeysBuilder<TDocument> GeoSpatialHaystack<TMember>(Expression
370375
/// <returns>
371376
/// The builder (so method calls can be chained).
372377
/// </returns>
378+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
373379
public static IndexKeysBuilder<TDocument> GeoSpatialHaystack<TMember, TAdditionalMember>(Expression<Func<TDocument, TMember>> memberExpression, Expression<Func<TDocument, TAdditionalMember>> additionalMemberExpression)
374380
{
375381
return new IndexKeysBuilder<TDocument>().GeoSpatialHaystack(memberExpression, additionalMemberExpression);
@@ -516,6 +522,7 @@ public IndexKeysBuilder<TDocument> GeoSpatial<TMember>(Expression<Func<TDocument
516522
/// <returns>
517523
/// The builder (so method calls can be chained).
518524
/// </returns>
525+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
519526
public IndexKeysBuilder<TDocument> GeoSpatialHaystack<TMember>(Expression<Func<TDocument, TMember>> memberExpression)
520527
{
521528
_indexKeysBuilder = _indexKeysBuilder.GeoSpatialHaystack(GetElementName(memberExpression));
@@ -532,6 +539,7 @@ public IndexKeysBuilder<TDocument> GeoSpatialHaystack<TMember>(Expression<Func<T
532539
/// <returns>
533540
/// The builder (so method calls can be chained).
534541
/// </returns>
542+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
535543
public IndexKeysBuilder<TDocument> GeoSpatialHaystack<TMember, TAdditionalMember>(Expression<Func<TDocument, TMember>> memberExpression, Expression<Func<TDocument, TAdditionalMember>> additionalMemberExpression)
536544
{
537545
_indexKeysBuilder = _indexKeysBuilder.GeoSpatialHaystack(GetElementName(memberExpression), GetElementName(additionalMemberExpression));

src/MongoDB.Driver.Legacy/Builders/IndexOptionsBuilder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public static IndexOptionsBuilder SetBits(int value)
6363
/// </summary>
6464
/// <param name="value">The bucket size.</param>
6565
/// <returns>The builder (so method calls can be chained).</returns>
66+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
6667
public static IndexOptionsBuilder SetBucketSize(double value)
6768
{
6869
return new IndexOptionsBuilder().SetBucketSize(value);
@@ -245,6 +246,7 @@ public IndexOptionsBuilder SetBits(int value)
245246
/// </summary>
246247
/// <param name="value">The bucket size.</param>
247248
/// <returns>The builder (so method calls can be chained).</returns>
249+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
248250
public IndexOptionsBuilder SetBucketSize(double value)
249251
{
250252
_document["bucketSize"] = value;
@@ -463,6 +465,7 @@ public static IndexOptionsBuilder<TDocument> SetBits(int value)
463465
/// </summary>
464466
/// <param name="value">The bucket size.</param>
465467
/// <returns>The builder (so method calls can be chained).</returns>
468+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
466469
public static IndexOptionsBuilder<TDocument> SetBucketSize(double value)
467470
{
468471
return new IndexOptionsBuilder<TDocument>().SetBucketSize(value);
@@ -652,6 +655,7 @@ public IndexOptionsBuilder<TDocument> SetBits(int value)
652655
/// </summary>
653656
/// <param name="value">The bucket size.</param>
654657
/// <returns>The builder (so method calls can be chained).</returns>
658+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
655659
public IndexOptionsBuilder<TDocument> SetBucketSize(double value)
656660
{
657661
_indexOptionsBuilder.SetBucketSize(value);

src/MongoDB.Driver.Legacy/CommandResults/GeoHaystackSearchResult.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace MongoDB.Driver
3030
#if NET452
3131
[Serializable]
3232
#endif
33+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
3334
public abstract class GeoHaystackSearchResult : CommandResult
3435
{
3536
// private fields
@@ -235,6 +236,7 @@ public int NumberOfHits
235236
[Serializable]
236237
#endif
237238
[BsonSerializer(typeof(GeoHaystackSearchResult<>.Serializer))]
239+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
238240
public class GeoHaystackSearchResult<TDocument> : GeoHaystackSearchResult
239241
{
240242
// private fields

src/MongoDB.Driver.Legacy/GeoHaystackSearchArgs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace MongoDB.Driver
2424
/// <summary>
2525
/// Represents the arguments to the GeoHaystackSearch method.
2626
/// </summary>
27+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
2728
public class GeoHaystackSearchArgs
2829
{
2930
// private fields

src/MongoDB.Driver.Legacy/MongoCollection.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,11 +987,13 @@ public virtual GeoHaystackSearchResult<TDocument> GeoHaystackSearchAs<TDocument>
987987
/// <typeparam name="TDocument">The type of the found documents.</typeparam>
988988
/// <param name="args">The args.</param>
989989
/// <returns>A <see cref="GeoNearResult{TDocument}"/>.</returns>
990+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
990991
public virtual GeoHaystackSearchResult<TDocument> GeoHaystackSearchAs<TDocument>(GeoHaystackSearchArgs args)
991992
{
992993
return UsingImplicitSession(session => GeoHaystackSearchAs<TDocument>(session, args));
993994
}
994995

996+
#pragma warning disable 618
995997
private GeoHaystackSearchResult<TDocument> GeoHaystackSearchAs<TDocument>(IClientSessionHandle session, GeoHaystackSearchArgs args)
996998
{
997999
if (args == null) { throw new ArgumentNullException("args"); }
@@ -1018,6 +1020,7 @@ private GeoHaystackSearchResult<TDocument> GeoHaystackSearchAs<TDocument>(IClien
10181020

10191021
return ExecuteReadOperation(session, operation);
10201022
}
1023+
#pragma warning restore 618
10211024

10221025
/// <summary>
10231026
/// Runs a geoHaystack search command on this collection.
@@ -1045,6 +1048,7 @@ public virtual GeoHaystackSearchResult GeoHaystackSearchAs(
10451048
/// <param name="documentType">The type to deserialize the documents as.</param>
10461049
/// <param name="args">The args.</param>
10471050
/// <returns>A <see cref="GeoNearResult{TDocument}"/>.</returns>
1051+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
10481052
public virtual GeoHaystackSearchResult GeoHaystackSearchAs(Type documentType, GeoHaystackSearchArgs args)
10491053
{
10501054
var methodDefinition = GetType().GetTypeInfo().GetMethod("GeoHaystackSearchAs", new Type[] { typeof(GeoHaystackSearchArgs) });
@@ -2410,6 +2414,7 @@ public virtual GeoHaystackSearchResult<TDefaultDocument> GeoHaystackSearch(
24102414
/// </summary>
24112415
/// <param name="args">The args.</param>
24122416
/// <returns>A <see cref="GeoHaystackSearchResult{TDocument}"/>.</returns>
2417+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
24132418
public virtual GeoHaystackSearchResult<TDefaultDocument> GeoHaystackSearch(GeoHaystackSearchArgs args)
24142419
{
24152420
return GeoHaystackSearchAs<TDefaultDocument>(args);

src/MongoDB.Driver/CreateIndexOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public int? Bits
6464
/// <summary>
6565
/// Gets or sets the size of a geohash bucket.
6666
/// </summary>
67+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
6768
public double? BucketSize
6869
{
6970
get { return _bucketSize; }
@@ -218,7 +219,9 @@ internal static CreateIndexOptions<TDocument> CoercedFrom(CreateIndexOptions opt
218219
{
219220
Background = options.Background,
220221
Bits = options.Bits,
222+
#pragma warning disable 618
221223
BucketSize = options.BucketSize,
224+
#pragma warning restore 618
222225
Collation = options.Collation,
223226
DefaultLanguage = options.DefaultLanguage,
224227
ExpireAfter = options.ExpireAfter,

src/MongoDB.Driver/IndexKeysDefinitionBuilder.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public static IndexKeysDefinition<TDocument> Geo2D<TDocument>(this IndexKeysDefi
129129
/// <returns>
130130
/// A combined index keys definition.
131131
/// </returns>
132+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
132133
public static IndexKeysDefinition<TDocument> GeoHaystack<TDocument>(this IndexKeysDefinition<TDocument> keys, FieldDefinition<TDocument> field, FieldDefinition<TDocument> additionalFieldName = null)
133134
{
134135
var builder = Builders<TDocument>.IndexKeys;
@@ -145,6 +146,7 @@ public static IndexKeysDefinition<TDocument> GeoHaystack<TDocument>(this IndexKe
145146
/// <returns>
146147
/// A combined index keys definition.
147148
/// </returns>
149+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
148150
public static IndexKeysDefinition<TDocument> GeoHaystack<TDocument>(this IndexKeysDefinition<TDocument> keys, Expression<Func<TDocument, object>> field, Expression<Func<TDocument, object>> additionalFieldName = null)
149151
{
150152
var builder = Builders<TDocument>.IndexKeys;
@@ -336,6 +338,7 @@ public IndexKeysDefinition<TDocument> Geo2D(Expression<Func<TDocument, object>>
336338
/// <returns>
337339
/// A geo haystack index key definition.
338340
/// </returns>
341+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
339342
public IndexKeysDefinition<TDocument> GeoHaystack(FieldDefinition<TDocument> field, FieldDefinition<TDocument> additionalFieldName = null)
340343
{
341344
return new GeoHaystackIndexKeyDefinition<TDocument>(field, additionalFieldName);
@@ -349,6 +352,7 @@ public IndexKeysDefinition<TDocument> GeoHaystack(FieldDefinition<TDocument> fie
349352
/// <returns>
350353
/// A geo haystack index key definition.
351354
/// </returns>
355+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
352356
public IndexKeysDefinition<TDocument> GeoHaystack(Expression<Func<TDocument, object>> field, Expression<Func<TDocument, object>> additionalFieldName = null)
353357
{
354358
FieldDefinition<TDocument> additional = additionalFieldName == null ? null : new ExpressionFieldDefinition<TDocument>(additionalFieldName);
@@ -502,6 +506,7 @@ public override BsonDocument Render(IBsonSerializer<TDocument> documentSerialize
502506
}
503507
}
504508

509+
[Obsolete("GeoHaystack indexes were deprecated in server version 4.4.")]
505510
internal sealed class GeoHaystackIndexKeyDefinition<TDocument> : IndexKeysDefinition<TDocument>
506511
{
507512
private readonly FieldDefinition<TDocument> _field;

src/MongoDB.Driver/MongoCollectionImpl.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,9 @@ private IEnumerable<CreateIndexRequest> CreateCreateIndexRequests(IEnumerable<Cr
15591559
Name = options.Name,
15601560
Background = options.Background,
15611561
Bits = options.Bits,
1562+
#pragma warning disable 618
15621563
BucketSize = options.BucketSize,
1564+
#pragma warning restore 618
15631565
Collation = options.Collation,
15641566
DefaultLanguage = options.DefaultLanguage,
15651567
ExpireAfter = options.ExpireAfter,

0 commit comments

Comments
 (0)