使用Java为MongoDB中的外部值分配权重

使用Java为MongoDB中的外部值分配权重,mongodb,Mongodb,这就是我如何在Mongo Shell中创建具有不同权重的索引的方法 db.blog.ensureIndex( { content: "text", keywords: "text", about: "text" }, {

这就是我如何在Mongo Shell中创建具有不同权重的索引的方法

             db.blog.ensureIndex(
                 {
                   content: "text",
                   keywords: "text",
                   about: "text"
                 },
                 {
                   weights: {
                              content: 10,
                              keywords: 5,
                            },
                   name: "TextIndex"
                 }
               )
    BasicDBObject index = new BasicDBObject();
        index.put("content", "text");
        index.put("keywords", "text");
        index.put("about", "text");

collection.ensureIndex( index, "TextIndex");
这就是我如何使用Java为字段创建索引的方法

             db.blog.ensureIndex(
                 {
                   content: "text",
                   keywords: "text",
                   about: "text"
                 },
                 {
                   weights: {
                              content: 10,
                              keywords: 5,
                            },
                   name: "TextIndex"
                 }
               )
    BasicDBObject index = new BasicDBObject();
        index.put("content", "text");
        index.put("keywords", "text");
        index.put("about", "text");

collection.ensureIndex( index, "TextIndex");

如何使用
Java
驱动程序分配权重?

Java
为索引字段分配权重:

    BasicDBObject index = new BasicDBObject();
    index.put("content", "text");
    index.put("keywords", "text");
    index.put("about", "text");
    BasicDBObject weights = new BasicDBObject("content", 10).append("keyword", 5);
    BasicDBObject options = new BasicDBObject("weights", weights).append("name", "TextIndex");
    collection.createIndex(index,options);

您能为我推荐一些关于ElasticSearch中要解决的上述问题的有用链接吗?请为以下链接提供解决方案: