List of usage examples for com.mongodb.client.model Indexes text
public static Bson text(final String fieldName)
From source file:connector.DBConnector.java
public static void StartConnection() { try {//from ww w . j a v a 2 s. c o m // To connect to mongodb server MongoClient mongoClient = new MongoClient(host, port); database = mongoClient.getDatabase("test"); MongoCollection<Document> coll = database.getCollection("tweets"); coll.createIndex(Indexes.text("text")); System.out.println("Connect to database successfully : " + database.getName()); } catch (Exception e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } }
From source file:io.lumeer.storage.mongodb.dao.collection.MongoDataDao.java
License:Open Source License
private void createFulltextIndexOnAllFields(final String collectionId) { dataCollection(collectionId).createIndex(Indexes.text("$**")); }
From source file:io.lumeer.storage.mongodb.dao.project.MongoViewDao.java
License:Open Source License
@Override public void createViewsRepository(Project project) { database.createCollection(databaseCollectionName(project)); MongoCollection<Document> projectCollection = database.getCollection(databaseCollectionName(project)); projectCollection.createIndex(Indexes.ascending(ViewCodec.CODE), new IndexOptions().unique(true)); projectCollection.createIndex(Indexes.ascending(ViewCodec.NAME), new IndexOptions().unique(true)); projectCollection.createIndex(Indexes.text(ViewCodec.NAME)); }