public Document getIndexOptions() { Document document = new Document(); if (StringUtils.hasText(name)) { document.put("name", name); } if (unique) { document.put("unique", true); } if (sparse) { document.put("sparse", true); } if (background) { document.put("background", true); } if (expire >= 0) { document.put("expireAfterSeconds", expire); } filter.ifPresent(val -> document.put("partialFilterExpression", val.getFilterObject())); collation.ifPresent(val -> document.append("collation", val.toDocument())); return document; }
@Nullable public Document getIndexOptions() { Document document = new Document(); if (StringUtils.hasText(name)) { document.put("name", name); } switch (type) { case GEO_2D: if (min != null) { document.put("min", min); } if (max != null) { document.put("max", max); } if (bits != null) { document.put("bits", bits); } break; case GEO_2DSPHERE: break; case GEO_HAYSTACK: document.put("bucketSize", bucketSize); break; } filter.ifPresent(val -> document.put("partialFilterExpression", val.getFilterObject())); collation.ifPresent(val -> document.append("collation", val.toDocument())); return document; }
@Override public Document getIndexOptions() { Document options = new Document(); if (StringUtils.hasText(name)) { options.put("name", name); } if (StringUtils.hasText(defaultLanguage)) { options.put("default_language", defaultLanguage); } Document weightsDocument = new Document(); for (TextIndexedFieldSpec fieldSpec : fieldSpecs) { if (fieldSpec.isWeighted()) { weightsDocument.put(fieldSpec.getFieldname(), fieldSpec.getWeight()); } } if (!weightsDocument.isEmpty()) { options.put("weights", weightsDocument); } if (StringUtils.hasText(languageOverride)) { options.put("language_override", languageOverride); } if (filter != null) { options.put("partialFilterExpression", filter.getFilterObject()); } return options; }
public Document getIndexOptions() { Document document = new Document(); if (StringUtils.hasText(name)) { document.put("name", name); } if (unique) { document.put("unique", true); } if (sparse) { document.put("sparse", true); } if (background) { document.put("background", true); } if (expire >= 0) { document.put("expireAfterSeconds", expire); } filter.ifPresent(val -> document.put("partialFilterExpression", val.getFilterObject())); collation.ifPresent(val -> document.append("collation", val.toDocument())); return document; }
@Nullable public Document getIndexOptions() { Document document = new Document(); if (StringUtils.hasText(name)) { document.put("name", name); } switch (type) { case GEO_2D: if (min != null) { document.put("min", min); } if (max != null) { document.put("max", max); } if (bits != null) { document.put("bits", bits); } break; case GEO_2DSPHERE: break; case GEO_HAYSTACK: document.put("bucketSize", bucketSize); break; } filter.ifPresent(val -> document.put("partialFilterExpression", val.getFilterObject())); collation.ifPresent(val -> document.append("collation", val.toDocument())); return document; }
@Override public Document getIndexOptions() { Document options = new Document(); if (StringUtils.hasText(name)) { options.put("name", name); } if (StringUtils.hasText(defaultLanguage)) { options.put("default_language", defaultLanguage); } Document weightsDocument = new Document(); for (TextIndexedFieldSpec fieldSpec : fieldSpecs) { if (fieldSpec.isWeighted()) { weightsDocument.put(fieldSpec.getFieldname(), fieldSpec.getWeight()); } } if (!weightsDocument.isEmpty()) { options.put("weights", weightsDocument); } if (StringUtils.hasText(languageOverride)) { options.put("language_override", languageOverride); } if (filter != null) { options.put("partialFilterExpression", filter.getFilterObject()); } return options; }