Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb Spring数据JPA-Mongo DB:回复消息长度5502322小于最大消息长度_Mongodb_Azure_Spring Data Jpa_Spring Data Mongodb - Fatal编程技术网

Mongodb Spring数据JPA-Mongo DB:回复消息长度5502322小于最大消息长度

Mongodb Spring数据JPA-Mongo DB:回复消息长度5502322小于最大消息长度,mongodb,azure,spring-data-jpa,spring-data-mongodb,Mongodb,Azure,Spring Data Jpa,Spring Data Mongodb,代码: MongoDB中的内容包括Base64图像以及ID、HTML。(并且只有11或12行) 客户的Azure Mongo DB版本

代码:

MongoDB中的内容包括Base64图像以及ID、HTML。(并且只有11或12行)

客户的Azure Mongo DB版本<3.2.0。而在本地,它大于3.2


在上面的代码中可以做哪些更改来分块阅读或限制它的工作?

您需要更改为:

"status": 500,
    "error": "Internal Server Error",
    "message": "The reply message length 5502322 is less than the maximum message length 4194304; nested exception is com.mongodb.MongoIn
ternalException: The reply message length 5502322 is less than the maximum message length 4194304",
编辑:

db.blog.aggregate([
    {$match:{"status": {$in: status} , "date":{ $lte: date }}},
    {$sort:{"date":-1}}
],{allowDiskUse:true})
import static org.springframework.data.mongodb.core.aggregation.aggregation.*;
...
//在您的“@Service”类中,包括:
@自动连线
私有MongoTemplate MongoTemplate;
...
匹配操作过滤器=匹配(标准。其中(“状态”)。处于(状态)和(“日期”)。lte(日期));
排序操作排序=排序(Direction.DESC,“日期”)
聚合=新聚合(筛选、排序)
.withOptions(新聚合选项()
.allowDiskUse(true.build());
AggregationResults=mongoTemplate.aggregate(聚合,mongoTemplate.getCollection(Blog.class),Blog.class);
List blogs=result.getMappedResults();

这是一个排序问题。您需要将MongoRepository方法更改为聚合查询,但如何在SpringDataJPA中执行此操作?因为当我在mongo db控制台中运行simple find query时,它会返回没有任何问题的结果。@fatherazrael我已经更新了我的答案,请看一看谢谢您的输入。我会测试一下,明天晚上给你回复。
db.blog.aggregate([
    {$match:{"status": {$in: status} , "date":{ $lte: date }}},
    {$sort:{"date":-1}}
],{allowDiskUse:true})
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
...

//Inside your `@Service` class, include:
@Autowired
private MongoTemplate mongotemplate;
...

MatchOperation filter = match(Criteria.where("status").in(status).and("date").lte(date));
SortOperation sort    = sort(Direction.DESC, "date")

Aggregation aggregation = newAggregation(filter, sort)
                             .withOptions(newAggregationOptions()
                             .allowDiskUse(true).build());
AggregationResults<Blog> result = mongoTemplate.aggregate(aggregation, mongoTemplate.getCollection(Blog.class), Blog.class);
List<Blog> blogs = result.getMappedResults();