Skip to content

Commit d83b259

Browse files
committed
Remove deprecated index-related methods
JAVA-5152
1 parent a0ccaf7 commit d83b259

File tree

16 files changed

+1
-144
lines changed

16 files changed

+1
-144
lines changed

driver-core/src/main/com/mongodb/client/model/IndexOptions.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public class IndexOptions {
4242
private Integer bits;
4343
private Double min;
4444
private Double max;
45-
private Double bucketSize;
4645
private Bson storageEngine;
4746
private Bson partialFilterExpression;
4847
private Collation collation;
@@ -371,33 +370,6 @@ public IndexOptions max(@Nullable final Double max) {
371370
return this;
372371
}
373372

374-
/**
375-
* Gets the specified the number of units within which to group the location values for geoHaystack Indexes
376-
*
377-
* @return the specified the number of units within which to group the location values for geoHaystack Indexes
378-
* @mongodb.driver.manual core/geohaystack/ geoHaystack Indexes
379-
* @deprecated geoHaystack is deprecated in MongoDB 4.4
380-
*/
381-
@Nullable
382-
@Deprecated
383-
public Double getBucketSize() {
384-
return bucketSize;
385-
}
386-
387-
/**
388-
* Sets the specified the number of units within which to group the location values for geoHaystack Indexes
389-
*
390-
* @param bucketSize the specified the number of units within which to group the location values for geoHaystack Indexes
391-
* @return this
392-
* @mongodb.driver.manual core/geohaystack/ geoHaystack Indexes
393-
* @deprecated geoHaystack is deprecated in MongoDB 4.4
394-
*/
395-
@Deprecated
396-
public IndexOptions bucketSize(@Nullable final Double bucketSize) {
397-
this.bucketSize = bucketSize;
398-
return this;
399-
}
400-
401373
/**
402374
* Gets the storage engine options document for this index.
403375
*
@@ -537,7 +509,6 @@ public String toString() {
537509
+ ", bits=" + bits
538510
+ ", min=" + min
539511
+ ", max=" + max
540-
+ ", bucketSize=" + bucketSize
541512
+ ", storageEngine=" + storageEngine
542513
+ ", partialFilterExpression=" + partialFilterExpression
543514
+ ", collation=" + collation

driver-core/src/main/com/mongodb/client/model/Indexes.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,6 @@ public static Bson geo2d(final String fieldName) {
127127
return new BsonDocument(fieldName, new BsonString("2d"));
128128
}
129129

130-
/**
131-
* Create an index key for a geohaystack index on the given field.
132-
*
133-
* <p>
134-
* <strong>Note: </strong>For queries that use spherical geometry, a 2dsphere index is a better option than a haystack index.
135-
* 2dsphere indexes allow field reordering; geoHaystack indexes require the first field to be the location field. Also, geoHaystack
136-
* indexes are only usable via commands and so always return all results at once..
137-
* </p>
138-
*
139-
* @param fieldName the field to create a geoHaystack index on
140-
* @param additional the additional field that forms the geoHaystack index key
141-
* @return the index specification
142-
* @mongodb.driver.manual core/geohaystack geoHaystack index
143-
* @deprecated geoHaystack is deprecated in MongoDB 4.4, prefer {@link Indexes#geo2dsphere(String...)}
144-
*/
145-
@Deprecated
146-
public static Bson geoHaystack(final String fieldName, final Bson additional) {
147-
notNull("fieldName", fieldName);
148-
return compoundIndex(new BsonDocument(fieldName, new BsonString("geoHaystack")), additional);
149-
}
150-
151130
/**
152131
* Create an index key for a text index on the given field.
153132
*

driver-core/src/main/com/mongodb/internal/bulk/IndexRequest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class IndexRequest {
5050
private Integer bits;
5151
private Double min;
5252
private Double max;
53-
private Double bucketSize;
5453
private boolean dropDups;
5554
private BsonDocument storageEngine;
5655
private BsonDocument partialFilterExpression;
@@ -216,18 +215,6 @@ public IndexRequest max(@Nullable final Double max) {
216215
return this;
217216
}
218217

219-
@Deprecated
220-
@Nullable
221-
public Double getBucketSize() {
222-
return bucketSize;
223-
}
224-
225-
@Deprecated
226-
public IndexRequest bucketSize(@Nullable final Double bucketSize) {
227-
this.bucketSize = bucketSize;
228-
return this;
229-
}
230-
231218
public boolean getDropDups() {
232219
return dropDups;
233220
}

driver-core/src/main/com/mongodb/internal/operation/CreateIndexesOperation.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ private BsonDocument getIndex(final IndexRequest request) {
200200
if (request.getMax() != null) {
201201
index.append("max", new BsonDouble(assertNotNull(request.getMax())));
202202
}
203-
if (request.getBucketSize() != null) {
204-
index.append("bucketSize", new BsonDouble(assertNotNull(request.getBucketSize())));
205-
}
206203
if (request.getDropDups()) {
207204
index.append("dropDups", BsonBoolean.TRUE);
208205
}

driver-core/src/main/com/mongodb/internal/operation/Operations.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ CreateViewOperation createView(final String viewName, final String viewOn, final
609609
assertNotNull(toBsonDocumentList(pipeline)), writeConcern).collation(createViewOptions.getCollation());
610610
}
611611

612-
@SuppressWarnings("deprecation")
613612
CreateIndexesOperation createIndexes(final List<IndexModel> indexes, final CreateIndexOptions createIndexOptions) {
614613
notNull("indexes", indexes);
615614
notNull("createIndexOptions", createIndexOptions);
@@ -633,7 +632,6 @@ CreateIndexesOperation createIndexes(final List<IndexModel> indexes, final Creat
633632
.bits(model.getOptions().getBits())
634633
.min(model.getOptions().getMin())
635634
.max(model.getOptions().getMax())
636-
.bucketSize(model.getOptions().getBucketSize())
637635
.storageEngine(toBsonDocument(model.getOptions().getStorageEngine()))
638636
.partialFilterExpression(toBsonDocument(model.getOptions().getPartialFilterExpression()))
639637
.collation(model.getOptions().getCollation())

driver-core/src/test/functional/com/mongodb/client/model/IndexesFunctionalSpecification.groovy

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
package com.mongodb.client.model
1818

1919
import com.mongodb.OperationFunctionalSpecification
20-
import spock.lang.IgnoreIf
2120

22-
import static com.mongodb.ClusterFixture.serverVersionAtLeast
2321
import static com.mongodb.client.model.Indexes.ascending
2422
import static com.mongodb.client.model.Indexes.compoundIndex
2523
import static com.mongodb.client.model.Indexes.descending
2624
import static com.mongodb.client.model.Indexes.geo2d
2725
import static com.mongodb.client.model.Indexes.geo2dsphere
28-
import static com.mongodb.client.model.Indexes.geoHaystack
2926
import static com.mongodb.client.model.Indexes.hashed
3027
import static com.mongodb.client.model.Indexes.text
3128
import static org.bson.BsonDocument.parse
@@ -100,15 +97,6 @@ class IndexesFunctionalSpecification extends OperationFunctionalSpecification {
10097
getCollectionHelper().listIndexes()*.get('key').contains(parse('{x : "2d"}'))
10198
}
10299

103-
@IgnoreIf({ serverVersionAtLeast(5, 0) })
104-
def 'geoHaystack'() {
105-
when:
106-
getCollectionHelper().createIndex(geoHaystack('x', descending('b')), 2.0)
107-
108-
then:
109-
getCollectionHelper().listIndexes()*.get('key').contains(parse('{x : "geoHaystack", b: -1}'))
110-
}
111-
112100
def 'text helper'() {
113101
when:
114102
getCollectionHelper().createIndex(text('x'))

driver-core/src/test/functional/com/mongodb/client/test/CollectionHelper.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,6 @@ public void createIndex(final Bson key) {
385385
WriteConcern.ACKNOWLEDGED).execute(getBinding());
386386
}
387387

388-
@SuppressWarnings("deprecation")
389-
public void createIndex(final Bson key, final Double bucketSize) {
390-
new CreateIndexesOperation(namespace, asList(new IndexRequest(key.toBsonDocument(Document.class, registry))
391-
.bucketSize(bucketSize)), WriteConcern.ACKNOWLEDGED).execute(getBinding());
392-
}
393-
394388
public List<BsonDocument> listIndexes(){
395389
List<BsonDocument> indexes = new ArrayList<>();
396390
BatchCursor<BsonDocument> cursor = new ListIndexesOperation<>(namespace, new BsonDocumentCodec()).execute(getBinding());

driver-core/src/test/functional/com/mongodb/internal/operation/CreateIndexesOperationSpecification.groovy

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,24 +334,6 @@ class CreateIndexesOperationSpecification extends OperationFunctionalSpecificati
334334
async << [true, false]
335335
}
336336

337-
@IgnoreIf({ serverVersionAtLeast(5, 0) })
338-
def 'should be able to create a geoHaystack indexes'() {
339-
given:
340-
def operation = new CreateIndexesOperation(getNamespace(),
341-
[new IndexRequest(new BsonDocument('field', new BsonString('geoHaystack')).append('field1', new BsonInt32(1)))
342-
.bucketSize(10.0)])
343-
344-
when:
345-
execute(operation, async)
346-
347-
then:
348-
getUserCreatedIndexes('key') == [[field: 'geoHaystack', field1: 1]]
349-
getUserCreatedIndexes('bucketSize') == [10.0]
350-
351-
where:
352-
async << [true, false]
353-
}
354-
355337
def 'should be able to create a 2dSphereIndex'() {
356338
given:
357339
def operation = new CreateIndexesOperation(getNamespace(),

driver-core/src/test/unit/com/mongodb/IndexRequestSpecification.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class IndexRequestSpecification extends Specification {
5050
request.getBits() == null
5151
request.getMin() == null
5252
request.getMax() == null
53-
request.getBucketSize() == null
5453
!request.getDropDups()
5554
request.getStorageEngine() == null
5655
request.getPartialFilterExpression() == null
@@ -89,7 +88,6 @@ class IndexRequestSpecification extends Specification {
8988
.bits(1)
9089
.min(-180.0)
9190
.max(180.0)
92-
.bucketSize(200.0)
9391
.dropDups(true)
9492
.storageEngine(storageEngine)
9593
.partialFilterExpression(partialFilterExpression)
@@ -113,7 +111,6 @@ class IndexRequestSpecification extends Specification {
113111
request2.getBits() == 1
114112
request2.getMin() == -180.0
115113
request2.getMax() == 180.0
116-
request2.getBucketSize() == 200.0
117114
request2.getDropDups()
118115
request2.getStorageEngine() == storageEngine
119116
request2.getPartialFilterExpression() == partialFilterExpression

driver-core/src/test/unit/com/mongodb/client/model/IndexOptionsSpecification.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class IndexOptionsSpecification extends Specification {
4242
options.getBits() == null
4343
options.getMin() == null
4444
options.getMax() == null
45-
options.getBucketSize() == null
4645
options.getStorageEngine() == null
4746
options.getPartialFilterExpression() == null
4847
options.getCollation() == null
@@ -69,7 +68,6 @@ class IndexOptionsSpecification extends Specification {
6968
.bits(1)
7069
.min(-180.0)
7170
.max(180.0)
72-
.bucketSize(200.0)
7371
.storageEngine(storageEngine)
7472
.partialFilterExpression(partialFilterExpression)
7573
.collation(collation)
@@ -91,7 +89,6 @@ class IndexOptionsSpecification extends Specification {
9189
options.getBits() == 1
9290
options.getMin() == -180.0
9391
options.getMax() == 180.0
94-
options.getBucketSize() == 200.0
9592
options.getStorageEngine() == storageEngine
9693
options.getPartialFilterExpression() == partialFilterExpression
9794
options.getCollation() == collation

driver-core/src/test/unit/com/mongodb/client/model/IndexesSpecification.groovy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import static com.mongodb.client.model.Indexes.compoundIndex
2525
import static com.mongodb.client.model.Indexes.descending
2626
import static com.mongodb.client.model.Indexes.geo2d
2727
import static com.mongodb.client.model.Indexes.geo2dsphere
28-
import static com.mongodb.client.model.Indexes.geoHaystack
2928
import static com.mongodb.client.model.Indexes.hashed
3029
import static com.mongodb.client.model.Indexes.text
3130
import static org.bson.BsonDocument.parse
@@ -58,11 +57,6 @@ class IndexesSpecification extends Specification {
5857
toBson(geo2d('x')) == parse('{x : "2d"}')
5958
}
6059

61-
def 'geoHaystack'() {
62-
expect:
63-
toBson(geoHaystack('x', descending('b'))) == parse('{x : "geoHaystack", b: -1}')
64-
}
65-
6660
def 'text helper'() {
6761
expect:
6862
toBson(text('x')) == parse('{x : "text"}')

driver-legacy/src/main/com/mongodb/DBCollection.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,9 +2107,6 @@ private CreateIndexesOperation createIndexOperation(final DBObject key, final DB
21072107
if (options.containsField("max")) {
21082108
request.max(convertOptionsToType(options, "max", Double.class));
21092109
}
2110-
if (options.containsField("bucketSize")) {
2111-
request.bucketSize(convertOptionsToType(options, "bucketSize", Double.class));
2112-
}
21132110
if (options.containsField("dropDups")) {
21142111
request.dropDups(convertOptionsToType(options, "dropDups", Boolean.class));
21152112
}

driver-legacy/src/test/functional/com/mongodb/DBCollectionSpecification.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class DBCollectionSpecification extends Specification {
155155
'expireAfterSeconds': 100, 'v': 1, 'weights': new BasicDBObject(['a': 1000]),
156156
'default_language': 'es', 'language_override': 'language', 'textIndexVersion': 1,
157157
'2dsphereIndexVersion': 1, 'bits': 1, 'min': new Double(-180.0),
158-
'max' : new Double(180.0), 'bucketSize': new Double(200.0), 'dropDups': true,
158+
'max' : new Double(180.0), 'dropDups': true,
159159
'storageEngine': BasicDBObject.parse(storageEngine),
160160
'partialFilterExpression': BasicDBObject.parse(partialFilterExpression),
161161
'collation': BasicDBObject.parse(collation.asDocument().toJson())]))
@@ -178,7 +178,6 @@ class DBCollectionSpecification extends Specification {
178178
.bits(1)
179179
.min(-180.0)
180180
.max(180.0)
181-
.bucketSize(200.0)
182181
.dropDups(true)
183182
.storageEngine(BsonDocument.parse(storageEngine))
184183
.partialFilterExpression(BsonDocument.parse(partialFilterExpression))

driver-scala/src/main/scala/org/mongodb/scala/model/Indexes.scala

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,6 @@ object Indexes {
7474
*/
7575
def geo2d(fieldName: String): Bson = JIndexes.geo2d(fieldName)
7676

77-
/**
78-
* Create an index key for a geohaystack index on the given field.
79-
*
80-
* <p>
81-
* <strong>Note: </strong>For queries that use spherical geometry, a 2dsphere index is a better option than a haystack index.
82-
* 2dsphere indexes allow field reordering; geoHaystack indexes require the first field to be the location field. Also, geoHaystack
83-
* indexes are only usable via commands and so always return all results at once..
84-
* </p>
85-
*
86-
* @param fieldName the field to create a geoHaystack index on
87-
* @param additional the additional field that forms the geoHaystack index key
88-
* @return the index specification
89-
* @see [[https://www.mongodb.com/docs/manual/core/geohaystack geoHaystack index]]
90-
*/
91-
@deprecated("geoHaystack is deprecated in MongoDB 4.4", "4.2.1")
92-
def geoHaystack(fieldName: String, additional: Bson): Bson = JIndexes.geoHaystack(fieldName, additional)
93-
9477
/**
9578
* Create an index key for a text index on the given field.
9679
*

driver-scala/src/test/scala/org/mongodb/scala/model/IndexesSpec.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ class IndexesSpec extends BaseSpec {
5959
toBson(geo2d("x")) should equal(Document("""{x : "2d"}"""))
6060
}
6161

62-
it should "geoHaystack" in {
63-
toBson(geoHaystack("x", descending("b"))) should equal(Document("""{x : "geoHaystack", b: -1}"""))
64-
}
65-
6662
it should "text" in {
6763
toBson(text("x")) should equal(Document("""{x : "text"}"""))
6864
}

driver-sync/src/test/unit/com/mongodb/client/internal/MongoCollectionSpecification.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,6 @@ class MongoCollectionSpecification extends Specification {
11961196
.bits(1)
11971197
.min(-180.0)
11981198
.max(180.0)
1199-
.bucketSize(200.0)
12001199
.storageEngine(BsonDocument.parse('{wiredTiger: {configString: "block_compressor=zlib"}}'))
12011200
.partialFilterExpression(BsonDocument.parse('{status: "active"}'))
12021201
.collation(collation)
@@ -1218,7 +1217,6 @@ class MongoCollectionSpecification extends Specification {
12181217
.bits(1)
12191218
.min(-180.0)
12201219
.max(180.0)
1221-
.bucketSize(200.0)
12221220
.storageEngine(BsonDocument.parse('{wiredTiger: {configString: "block_compressor=zlib"}}'))
12231221
.partialFilterExpression(BsonDocument.parse('{status: "active"}'))
12241222
.collation(collation)

0 commit comments

Comments
 (0)