use of org.springframework.data.mongodb.core.index.IndexOperations in project spring-data-mongodb by spring-projects.
the class GeoSpatial2DSphereTests method indexInfoIsCorrect.
// DATAMONGO-360
@Test
public void indexInfoIsCorrect() {
IndexOperations operations = template.indexOps(Venue.class);
List<IndexInfo> indexInfo = operations.getIndexInfo();
assertThat(indexInfo.size(), is(2));
List<IndexField> fields = indexInfo.get(0).getIndexFields();
assertThat(fields.size(), is(1));
assertThat(fields, hasItem(IndexField.create("_id", Direction.ASC)));
fields = indexInfo.get(1).getIndexFields();
assertThat(fields.size(), is(1));
assertThat(fields, hasItem(IndexField.geo("location")));
}
use of org.springframework.data.mongodb.core.index.IndexOperations in project spring-data-mongodb by spring-projects.
the class GeoSpatial2DTests method indexInfoIsCorrect.
// DATAMONGO-360
@Test
public void indexInfoIsCorrect() {
IndexOperations operations = template.indexOps(Venue.class);
List<IndexInfo> indexInfo = operations.getIndexInfo();
assertThat(indexInfo.size(), is(2));
List<IndexField> fields = indexInfo.get(0).getIndexFields();
assertThat(fields.size(), is(1));
assertThat(fields, hasItem(IndexField.create("_id", Direction.ASC)));
fields = indexInfo.get(1).getIndexFields();
assertThat(fields.size(), is(1));
assertThat(fields, hasItem(IndexField.geo("location")));
}
use of org.springframework.data.mongodb.core.index.IndexOperations in project spring-data-mongodb by spring-projects.
the class TextQueryTests method setUp.
@Before
public void setUp() {
IndexOperations indexOps = template.indexOps(FullTextDoc.class);
indexOps.dropAllIndexes();
indexOps.ensureIndex(new IndexDefinition() {
@Override
public Document getIndexOptions() {
Document options = new Document();
options.put("weights", weights());
options.put("name", "TextQueryTests_TextIndex");
options.put("language_override", "lang");
options.put("default_language", "english");
return options;
}
@Override
public Document getIndexKeys() {
Document keys = new Document();
keys.put("headline", "text");
keys.put("subheadline", "text");
keys.put("body", "text");
return keys;
}
private Document weights() {
Document weights = new Document();
weights.put("headline", 10);
weights.put("subheadline", 5);
weights.put("body", 1);
return weights;
}
});
}
use of org.springframework.data.mongodb.core.index.IndexOperations in project spring-data-mongodb by spring-projects.
the class GeoSpatialIndexTests method useGeneratedNameShouldGenerateAnIndexName.
// DATAMONGO-827
@Test
public void useGeneratedNameShouldGenerateAnIndexName() {
try {
GeoSpatialEntity2dWithGeneratedIndex geo = new GeoSpatialEntity2dWithGeneratedIndex(45.2, 4.6);
template.save(geo);
IndexOperations indexOps = template.indexOps(GeoSpatialEntity2dWithGeneratedIndex.class);
List<IndexInfo> indexInfo = indexOps.getIndexInfo();
assertThat(indexInfo, hasSize(2));
assertThat(indexInfo.get(1), is(notNullValue()));
assertThat(indexInfo.get(1).getName(), is("location_2d"));
} finally {
template.dropCollection(GeoSpatialEntity2D.class);
}
}
Aggregations