SEO技术

SEO技术

Products

当前位置:首页 > SEO技术 >

网站是如何由多个网页组成,并包含哪些建设网站的参考文献?

96SEO 2026-02-19 08:55 9


Springboot

方式#xff0c;这种操作方式#xff0c;使用简单但是灵活性比较差。

网站是如何由多个网页组成,并包含哪些建设网站的参考文献?

第二种方式是采用

Spring

MongoTemplate提供了insert()方法用于插入文档示例代码如下

用于插入文档

Person();person.setId(1l);person.setUserName(张三);person.setPassWord(123456);person.setCreateTime(new

Date());mongoTemplate.insert(person);}

自定义集合名称插入文档

Person();person.setId(1l);person.setUserName(张三);person.setPassWord(123456);person.setCreateTime(new

Date());mongoTemplate.insert(person,

custom_person);}

Person();person1.setId(10l);person1.setUserName(张三);person1.setPassWord(123456);person1.setCreateTime(new

Date());personList.add(person1);Person

person2

Person();person2.setId(11l);person2.setUserName(李四);person2.setPassWord(123456);person2.setCreateTime(new

Date());personList.add(person2);mongoTemplate.insert(personList,

custom_person);}

MongoTemplate提供了save()方法用于存储文档。

在存储文档的时候会通过主键ID进行判断如果存在就更新否则就插入示例代码如下

SpringBootTest

Person();person.setId(13l);person.setUserName(八八);person.setPassWord(123456);person.setAge(40);person.setCreateTime(new

Date());mongoTemplate.save(person);}

自定义集合存储文档

Person();person.setId(1l);person.setUserName(张三);person.setPassWord(123456);person.setCreateTime(new

Date());mongoTemplate.save(person,

custom_person);}

MongoTemplate提供了updateFirst()和updateMulti()方法用于更新文档示例代码如下

SpringBootTest

Person();person.setId(1l);person.setUserName(张三123);person.setPassWord(123456);person.setCreateTime(new

Date());//更新条件Query

Query(Criteria.where(id).is(person.getId()));//更新值Update

update

person.getUserName()).set(passWord,

person.getPassWord());//更新查询满足条件的文档数据第一条UpdateResult

result

mongoTemplate.updateFirst(query,update,

Person.class);if(result!null){System.out.println(更新条数

SpringBootTest

Person();person.setId(1l);person.setUserName(张三);person.setPassWord(123456);person.setCreateTime(new

Date());//更新条件Query

Query(Criteria.where(id).is(person.getId()));//更新值Update

update

person.getUserName()).set(passWord,

person.getPassWord());//更新查询满足条件的文档数据全部UpdateResult

result

mongoTemplate.updateMulti(query,

update,

Person.class);if(result!null){System.out.println(更新条数

删除文档

MongoTemplate提供了remove()、findAndRemove()和findAllAndRemove()方法用于删除文档示例代码如下

SpringBootTest

Person();person.setId(1l);person.setUserName(张三);person.setPassWord(123456);person.setCreateTime(new

Date());Query

Query(Criteria.where(userName).is(person.getUserName()));DeleteResult

result

Person.class);System.out.println(删除条数

SpringBootTest

Person();person.setId(1l);person.setUserName(张三);person.setPassWord(123456);person.setCreateTime(new

Date());Query

Query(Criteria.where(id).is(person.getId()));Person

result

mongoTemplate.findAndRemove(query,

Person.class);System.out.println(删除的文档数据

result.toString());}

Person();person.setId(1l);person.setUserName(张三);person.setPassWord(123456);person.setCreateTime(new

Date());Query

Query(Criteria.where(id).is(person.getId()));ListPerson

result

mongoTemplate.findAllAndRemove(query,

Person.class);System.out.println(删除的文档数据

result.toString());}

MongoTemplate提供了非常多的文档查询方法日常开发中用的最多的就是find()方法示例代码如下

SpringBootTest

mongoTemplate.findAll(Person.class);System.out.println(查询结果

result.toString());}

Person.class);System.out.println(查询结果

result.toString());}

根据条件查询集合中符合条件的文档返回第一条数据*/Testpublic

void

Query(Criteria.where(userName).is(userName));Person

result

Person.class);System.out.println(查询结果

result.toString());}

Query(Criteria.where(userName).is(userName));ListPerson

result

Person.class);System.out.println(查询结果

result.toString());}

根据【AND】关联多个查询条件查询集合中的文档数据*/Testpublic

void

Criteria.where(userName).is(张三);Criteria

criteriaPassWord

Criteria.where(passWord).is(123456);//

创建条件对象将上面条件进行

Criteria().andOperator(criteriaUserName,

criteriaPassWord);//

Person.class);System.out.println(查询结果

result.toString());}

根据【OR】关联多个查询条件查询集合中的文档数据*/Testpublic

void

Criteria.where(userName).is(张三);Criteria

criteriaPassWord

Criteria.where(passWord).is(123456);//

创建条件对象将上面条件进行

Criteria().orOperator(criteriaUserName,

criteriaPassWord);//

Person.class);System.out.println(查询结果

result.toString());}

根据【IN】关联多个查询条件查询集合中的文档数据*/Testpublic

void

Person.class);System.out.println(查询结果

result.toString());}

根据【逻辑运算符】查询集合中的文档数据*/Testpublic

void

Criteria.where(age).gt(min).lte(max);//

query

Person.class);System.out.println(查询结果

result.toString());}

根据【正则表达式】查询集合中的文档数据*/Testpublic

void

Criteria.where(userName).regex(regex);//

query

Person.class);System.out.println(查询结果

result.toString());}

根据条件查询集合中符合条件的文档获取其文档列表并排序*/Testpublic

void

Query(Criteria.where(userName).is(userName)).with(Sort.by(age));ListPerson

result

Person.class);System.out.println(查询结果

result.toString());}

根据单个条件查询集合中的文档数据并按指定字段进行排序与限制指定数目

SpringBootTest

根据单个条件查询集合中的文档数据并按指定字段进行排序与限制指定数目*/Testpublic

void

Query(Criteria.where(userName).is(userName)).with(Sort.by(createTime)).limit(2).skip(1);ListPerson

result

Person.class);System.out.println(查询结果

result.toString());}

统计集合中符合【查询条件】的文档【数量】*/Testpublic

void

Criteria.where(userName).regex(regex);//

query

Person.class);System.out.println(统计结果

count);}

Query.query(Criteria.where(userId).is(1L));query.fields().include(pid).exclude(_id);/*Expected

read

pid2031}*{_id5fae53927e52992e78a3aed9,

pid2032}*{_id5fae53927e52992e78a3aee5,

pid2033}*

quanzi_publish);result.forEach(System.out::println);}通过query点fields

include

虽然只有一个字段。

但是从mongodb查询出来的应该是一个json对象。

对象的属性只有一个。

没有去看mongodb底层。

但应该是做了json的解析。

Test

Query.query(Criteria.where(userId).is(1L));ListMyLong

result

result.stream().map(MyLong::getPid).collect(Collectors.toList());pids.forEach(System.out::println);

}class

流转为了long类型的list集合。

这样做感觉也挺麻烦。

但是如果集合字段特别多的话。

这样应该能提升一些性能。

毕竟如果直接读取整个集合也是需要遍历。

然后提取出id

到一个新集合。

步骤差不多。

这样只是从mongodb只读取了需要的数据。

String

Query();query.with(Sort.by(Sort.Direction.DESC,

age));ListStudent

设置分页信息query.limit(pageSize);query.skip(pageSize

(currentPage

query.addCriteria(Criteria.where(clazzName).regex(天));ListClazz

clazzes

Query();query.addCriteria(Criteria.where(age).gte(6).lte(18));query.with(Sort.by(Sort.Direction.ASC,

age));query.addCriteria(Criteria.where(name).regex(小));//

模糊查询名字Long

Aggregation.newAggregation(lookup,Aggregation.match(criteria),Aggregation.group(startSolitaireId)

分组的字段.first(startSolitaireId).as(startSolitaireId)

并取别名.first(userId).as(userId).first(interact).as(interact).first(createTime).as(createTime).first(startVO).as(startVO),Aggregation.sort(Sort.Direction.DESC,createTime),

page.getCurrent()

page.getSize()),Aggregation.limit(page.getSize()));

MongoDB

org.springframework.data.domain.Sort;

import

org.springframework.data.mongodb.core.MongoTemplate;

import

org.springframework.data.mongodb.core.aggregation.Aggregation;

import

org.springframework.data.mongodb.core.aggregation.AggregationOperation;

import

org.springframework.data.mongodb.core.aggregation.AggregationResults;

import

org.springframework.stereotype.Service;

import

进行分组然后统计各个组的文档数量AggregationOperation

group

Aggregation.group(age).count().as(numCount);//

aggregation

Aggregation.newAggregation(group);//

results

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

使用管道操作符

进行分组然后统计各个组文档某字段最大值AggregationOperation

group

Aggregation.group(sex).max(salary).as(salaryMax);//

aggregation

Aggregation.newAggregation(group);//

results

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

使用管道操作符

进行分组然后统计各个组文档某字段最小值AggregationOperation

group

Aggregation.group(sex).min(salary).as(salaryMin);//

aggregation

Aggregation.newAggregation(group);//

results

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

使用管道操作符

进行分组然后统计各个组文档某字段值合计AggregationOperation

group

Aggregation.group(sex).sum(salary).as(salarySum);//

aggregation

Aggregation.newAggregation(group);//

results

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

使用管道操作符

进行分组然后统计各个组文档某字段值平均值AggregationOperation

group

Aggregation.group(sex).avg(salary).as(salaryAvg);//

aggregation

Aggregation.newAggregation(group);//

results

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

使用管道操作符

进行分组最后统计各个组文档某字段值第一个值AggregationOperation

sort

Aggregation.sort(Sort.by(salary).ascending());AggregationOperation

group

Aggregation.group(sex).first(salary).as(salaryFirst);//

aggregation

Aggregation.newAggregation(sort,

group);//

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

使用管道操作符

进行分组最后统计各个组文档某字段值第最后一个值AggregationOperation

sort

Aggregation.sort(Sort.by(salary).ascending());AggregationOperation

group

Aggregation.group(sex).last(salary).as(salaryLast);//

aggregation

Aggregation.newAggregation(sort,

group);//

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

使用管道操作符

进行分组然后以数组形式列出某字段的全部值AggregationOperation

push

Aggregation.group(sex).push(salary).as(salaryFirst);//

aggregation

Aggregation.newAggregation(push);//

results

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}}聚合管道操作符

import

org.springframework.data.domain.Sort;

import

org.springframework.data.mongodb.core.MongoTemplate;

import

org.springframework.data.mongodb.core.aggregation.Aggregation;

import

org.springframework.data.mongodb.core.aggregation.AggregationOperation;

import

org.springframework.data.mongodb.core.aggregation.AggregationResults;

import

org.springframework.data.mongodb.core.query.Criteria;

import

org.springframework.stereotype.Service;

import

的用户然后按性别分组统计每组用户工资最高值AggregationOperation

match

Aggregation.match(Criteria.where(age).lt(25));AggregationOperation

group

Aggregation.group(sex).max(salary).as(sexSalary);//

aggregation

Aggregation.newAggregation(match,

group);//

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

$group

设置聚合条件按岁数分组然后统计每组用户工资最大值和用户数按每组用户工资最大值升序排序AggregationOperation

group

Aggregation.group(age).max(salary).as(ageSalary).count().as(ageCount);AggregationOperation

sort

Aggregation.sort(Sort.by(ageSalary).ascending());//

aggregation

Aggregation.newAggregation(group,

sort);//

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

$group

设置聚合条件先按岁数分组然后求每组用户的工资总数、最大值、最小值、平均值限制只能显示五条AggregationOperation

group

Aggregation.group(age).sum(salary).as(sumSalary).max(salary).as(maxSalary).min(salary).as(minSalary).avg(salary).as(avgSalary);AggregationOperation

limit

Aggregation.newAggregation(group,

limit);//

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

$group

设置聚合条件先按岁数分组然后求每组用户的工资总数、最大值、最小值、平均值跳过前

group

Aggregation.group(age).sum(salary).as(sumSalary).max(salary).as(maxSalary).min(salary).as(minSalary).avg(salary).as(avgSalary);AggregationOperation

limit

Aggregation.newAggregation(group,

limit);//

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

$group

设置聚合条件,按岁数分组然后求每组用户工资最大值、最小值然后使用

$project

Aggregation.group(age).max(salary).as(maxSalary).min(salary).as(minSalary);AggregationOperation

project

Aggregation.project(maxSalary);//

aggregation

Aggregation.newAggregation(group,

project);//

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}/***

$group

设置聚合条件设置显示name、age、title字段然后将结果中的多条文档按

title

Aggregation.newAggregation(project,

unwind);//

mongoTemplate.aggregate(aggregation,

COLLECTION_NAME,

results.getMappedResults();}}聚合管道操作符

$project

可以从文档中选择想要的字段和不想要的字段指定的字段可以是来自输入文档或新计算字段的现有字段

也可以通过管道表达式进行一些复杂的操作例如数学操作日期操作字符串操作逻辑操作。

**

match**

match∗∗用于过滤数据只输出符合条件的文档。

match使用MongoDB的标准查询操作。

$limit

在聚合管道中跳过指定数量的文档并返回余下的文档。

$unwind

将文档中的某一个数组类型字段拆分成多条每条包含数组中的一个值。

$group

关联查询

LookupOperation这个类就是用来进行联表操作的类具体方法

newLookup

用来创建一个LookupOperation.Builderfrom

要连接哪张表类似Mysql的JOINlocalField主表哪个字段去连接指明出来from表参考主表的哪个字段foreignField

从表结果集名最后会在主表多出这个自定义列默认List理解为as一个别名会把从表的数据以数组的形式在as字段内

表结构

ISODate(2022-03-23T08:13:19.694Z),updateTime:

ISODate(2022-03-23T08:13:19.694Z),iStatus:

NumberInt(0)

查询(只能是主表的字段取别名字段不可以例如item.sName

Criteria

Criteria.where(sUserId).is(444);

就as自定义列名点属性

查询Aggregation.match(criteria),//

将某个集合列拆成字段添加主表Aggregation.unwind(item),//

排序Aggregation.sort(Sort.Direction.DESC,

createTime),//

mongoTemplate.aggregate(aggregation,

ItemUser,

aggregationResults.getMappedResults();

前面提到as会在主表新增个列列里内容是数组Aggregation.unwind(“item”)的作用就是把as列里数组拆掉通过ProjectionOperation

加在主表自定义字段中

LookupOperation.newLookup().from(adrs).//1.副表表名字localField(_id).//2.主表的关联字段foreignField(adrsId).//3.副表的关联字段as(adrs);//4.建议和1一致结果的别名//关联多张表就写多个

LookupOperation

as(adrs);//多表的关联条件查询条件均传入到此Aggregation

aggregation

Aggregation.newAggregation(cusAndInfoLookup,

cusAndInfoLookup1,

Aggregation.match(Criteria.where(_id).lte(2)),//5.此作用处下文解释

Aggregation.unwind(adrs),//筛选条件筛选主表的字段直接写副表则是别名.字段名Aggregation.match(Criteria.where(adrs.adrsId).is(1)));//5.此处填写主表名称AggregationResultsJSONObject

results

mongoTemplate.aggregate(aggregation,

tab_map,

JSONObject.class);ListJSONObject

objectList

unwind的作用默认关联查询出现多个关联值时结果会以array返回例如一个用户有多个收货地址则会返回

{id:1,adrs:{adrs1}}

####分组两表三表联查###########################################################

import

com.csw.mongodbspringbootdemo.entity.Chair;

import

com.csw.mongodbspringbootdemo.entity.Desk;

import

com.csw.mongodbspringbootdemo.entity.Room;

import

org.springframework.beans.factory.annotation.Autowired;

import

org.springframework.boot.test.context.SpringBootTest;

import

org.springframework.data.domain.Sort;

import

org.springframework.data.mongodb.core.MongoTemplate;

import

org.springframework.data.mongodb.core.aggregation.Aggregation;

import

org.springframework.data.mongodb.core.aggregation.AggregationOperation;

import

org.springframework.data.mongodb.core.aggregation.AggregationResults;

import

org.springframework.data.mongodb.core.aggregation.LookupOperation;

import

org.springframework.data.mongodb.core.query.Criteria;

import

org.springframework.data.mongodb.core.query.Query;

import

org.springframework.test.context.junit4.SpringRunner;import

java.util.ArrayList;

Room();room.setName(空房间2);room.setUnitCode(UUID.randomUUID().toString());mongoTemplate.save(room);Room

room2

Room();room2.setName(空房间1);room2.setUnitCode(UUID.randomUUID().toString());mongoTemplate.save(room2);}Testpublic

void

Query(Criteria.where(name).is(roomName));Room

room

Desk();desk.setName(deskName);assert

room

null;desk.setUnitCode(room.getUnitCode());mongoTemplate.save(desk);System.out.println(room);Query

query2

Query(Criteria.where(name).is(deskName));Desk

desk2

Desk.class);System.out.println(desk2);}Testpublic

void

aggs.add(Aggregation.match(Criteria.where(name).is(log)));aggs.add(Aggregation.group(name).count().as(count));aggs.add(Aggregation.project().and(_id).as(name).and(count).as(count));Aggregation

agg

Aggregation.newAggregation(aggs);AggregationResultsMap

results

{System.out.println(result);}}Testpublic

void

LookupOperation.newLookup().from(room).

查询结果集合名Criteria

Criteria.where(rooms).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi

Aggregation.match(ordercri);Aggregation

aggregation

Aggregation.newAggregation(lookupOperation,

matchZi);//

mongoTemplate.aggregate(aggregation,

desk,

{System.out.println(result);}}Testpublic

void

LookupOperation.newLookup().from(desk).

查询结果集合名Criteria

Criteria.where(desks).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi

Aggregation.match(ordercri);Aggregation

aggregation

Aggregation.newAggregation(lookupOperation,

matchZi);//

mongoTemplate.aggregate(aggregation,

room,

{System.out.println(result);}}Testpublic

void

LookupOperation.newLookup().from(room).

从表关联字段对应的次表字段as(ClazzStudents);//

查询结果集合名//

Criteria.where(ClazzStudents).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi

Criteria.where(name).regex(号);//

只查询名字中带有文的人AggregationOperation

matchFu

Aggregation.newAggregation(matchFu,

lookupOperation,

matchZi,Aggregation.sort(Sort.Direction.DESC,

name),Aggregation.skip(pageSize

(pageNumber

Aggregation.limit(pageSize));//

排序//

Aggregation.skip(pageable.getPageNumber()1?(pageable.getPageNumber()-1)*pageable.getPageSize():0),//pagenumber//

分页/**

Aggregation.skip(pageSize1?(pageNumber-1)*pageSize:0);*

Aggregation.limit(pageSize);*///

总数查询Aggregation

Aggregation.newAggregation(matchFu,

lookupOperation,

mongoTemplate.aggregate(counts,

Desk.class,

BasicDBObject.class).getMappedResults().size();System.out.println(【count】

count);ListMap

mongoTemplate.aggregate(aggregation,

desk,

{System.out.println(result);}}Testpublic

void

Query(Criteria.where(name).is(roomName));Room

room

Chair();chair.setName(chairName);assert

room

null;chair.setUnitCode(room.getUnitCode());mongoTemplate.save(chair);}Testpublic

void

三表联查测试第一个表关联第二个人表关联字段1第一个表关联第三个表关联字段1LookupOperation

lookupOperation

LookupOperation.newLookup().from(desk).

查询结果集合名Criteria

Criteria.where(desks).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi

Aggregation.match(ordercri);LookupOperation

lookupOperation2

LookupOperation.newLookup().from(chair).

查询结果集合名Criteria

Criteria.where(chairs).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi2

Aggregation.match(ordercri2);Aggregation

aggregation

Aggregation.newAggregation(lookupOperation,

matchZi,

mongoTemplate.aggregate(aggregation,

room,

{System.out.println(result);}}//

数据模拟Testpublic

三表联查测试第一个表关联第二个人表关联字段1第一个表关联第三个表关联字段2LookupOperation

lookupOperation

LookupOperation.newLookup().from(desk).

查询结果集合名Criteria

Criteria.where(desks).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi

Aggregation.match(ordercri);LookupOperation

lookupOperation2

LookupOperation.newLookup().from(chair).

查询结果集合名Criteria

Criteria.where(chairs).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi2

Aggregation.match(ordercri2);Aggregation

aggregation

Aggregation.newAggregation(lookupOperation,

matchZi,

mongoTemplate.aggregate(aggregation,

room,

{System.out.println(result);}}//

数据模拟Testpublic

三表联查测试第一个表关联第二个人表关联字段1第二个表关联第三个表关联字段2LookupOperation

lookupOperation

LookupOperation.newLookup().from(room).

查询结果集合名Criteria

Criteria.where(rooms).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi

Aggregation.match(ordercri);LookupOperation

lookupOperation2

LookupOperation.newLookup().from(chair).

关联表名localField(rooms.lastCode).

查询结果集合名Criteria

Criteria.where(chairs).not().size(0);//

ordercri.and(age).gte(1).lte(5);//只查询1岁到5岁的宠物AggregationOperation

matchZi2

Aggregation.match(ordercri2);Aggregation

aggregation

Aggregation.newAggregation(lookupOperation,

matchZi,

mongoTemplate.aggregate(aggregation,

desk,

聚合函数将某个字段或者某个数组作为分组统计的依据,在group的基础上又扩展出以下函数

sum()

过滤函数主要存储过滤数据的条件输出符合条件的记录Aggregation.project():

修改数据结构函数,将前面管道中的获取的字段进行重名,增加修改字段等操作。

Aggregation.unwind()将文档中的某一个数组类型字段拆分成多条每条包含数组中的一个值。

当preserveNullAndEmptyArrays为true时将包括字段为null空或者缺失的数据;Aggregation.sort():

排序函数将上级管道的内容按照某个字段进行排序并且输出。

值为1升、-1降。

sort一般放在group后,也就是说得到结果后再排序如果先排序再分组没什么意义;Aggregation.limit():

限制输出函数将聚合返回的内容限定在某个条目之内。

通常作为页面大小Aggregation.skip():

跳过指定数量的条目再开始返回数据的函数通常和sort()limit()配合实现数据翻页查询等操作。

Aggregation.lookup():

Copymongodb

db.getCollection(mro_fn_subscribes).aggregate([{$group:{_id:{_id:$accountId,

status:

$status},codeAvg:{$avg:$fnCode},codeMax:{$max:$fnCode},codeMin:{$min:$fnCode},codeFirst:{$first:$fnCode},codeLast:{$last:$fnCode},}}

])java:

Aggregation.newAggregation(Aggregation.group(accountId,

status).count().as(count).sum(status).as(statusSum).avg(fnCode).as(codeAvg).max(fnCode).as(codeMax).min(fnCode).as(codeMin).first(fnCode).as(codeFirst).last(fnCode).as(codeLast)

Copymongodb

db.getCollection(mro_fn_subscribes).aggregate({$match:{userId:a}}

)java:

Aggregation.newAggregation(Aggregation.match(new

);project筛选字段:

db.getCollection(mro_fn_subscribes).aggregate([{$group

{_id

Aggregation.newAggregation(Aggregation.group(new

String[]

{_id}).sum(num).as(num).first(name).as(firstName).last(name).as(lastName),Aggregation.project(_id,

num,

firstName).and(lastName).as(name)

重新命名字段

db.col.aggregate({$match:{userid:a}},

includeArrayIndex:

Aggregation.newAggregation(Aggregation.match(new

Criteria().and(userId).is(a),Aggregation.unwind(items,true)

);sort

db.getCollection(mro_fn_subscribes).aggregate([{$group

status:

Aggregation.newAggregation(Aggregation.group(accountId,

status)Aggregation.sort(Direction.DESC,

num),

//从第10条记录开始Aggregation.limit(2)

//取两条数据

db.getCollection(mro_accounts).aggregate([{$lookup:

{from:mro_profiles,

主表mro_accounts中用于关联的字段foreignField:mobile,

被关联表mro_profiles中用于关联的字段as:profileDoc

Java

Aggregation.newAggregation(Aggregation.lookup(mro_profiles,

userName,

mongotemplate.aggregate(aggregation,

“mro_fn_subscribes”,

Fnsubscribe.class).getMappedResults()

日期字符串转ISO日期格式mogodb

ZoneId.systemDefault();DateTimeFormatter

DateTimeFormatter.ofPattern(yyyy-MM-dd

birthDate

birthDate.atZone(zone).toInstant();Date

date

Date.from(instant);System.out.println(birthDate:

birthDate);System.out.println(instant:

instant);System.out.println(date:

date);}支持

MongoDB是用于与MongoDB数据库进行交互的框架提供了许多功能强大的

API

和管理工具其中包含了大量数据操作函数包括数组聚合运算符$filter也是其中一种。

在MongoDB中当需要使用聚合函数过滤数组中的元素时可以使用$filter运算符。

具体使用方法如下

$project:

MongoDB中$filter运算符同样被支持。

可以使用AggregationOperation来拼接查询条件。

具体实现代码如下

AggregationOperation

.andFilter(ArrayOperators.Filter

.filter(array)

.by(ComparisonOperators.Gt.valueOf($$element).greaterThan(5)))

.as(filteredArray);在上述代码中使用了ArrayOperators.Filter来表示$filter运算符并使用ComparisonOperators.Gt来表示’符号从而实现了对数组中元素进行筛选。

操作符只适用于聚合操作中即使用聚合函数进行筛选。

如果想要在数据操作中对数组中的元素进行筛选则需要使用

filter操作符只适用于聚合操作中即使用聚合函数进行筛选。

如果想要在数据操作中对数组中的元素进行筛选则需要使用

filter操作符只适用于聚合操作中即使用聚合函数进行筛选。

如果想要在数据操作中对数组中的元素进行筛选则需要使用elemMatch操作符来实现。

具体操作方法可参考以下代码

Criteria

Criteria.where(array).elemMatch(

Query

DBObject.class,collectionName);上述代码使用$elemMatch操作符来筛选数组中所有大于5的元素并使用mongoTemplate.find方法来获取符合条件的数据项。

扩展的相关知识点也非常广泛如MongoDB聚合函数的使用、Java

Spring

MongoDB的API使用、MongoDB数据库的操作等。

在实际应用过程中需要注意的是在使用聚合函数进行操作时应尽量避免数据过多而导致的性能可以采用分批次操作的方法来进行优化。

同时需要根据实际情况来选择

elemMatch或者

elemMatch或者filter操作符以及其他更合适的操作函数来实现查询需求。

1、菜鸟教程



SEO优化服务概述

作为专业的SEO优化服务提供商,我们致力于通过科学、系统的搜索引擎优化策略,帮助企业在百度、Google等搜索引擎中获得更高的排名和流量。我们的服务涵盖网站结构优化、内容优化、技术SEO和链接建设等多个维度。

百度官方合作伙伴 白帽SEO技术 数据驱动优化 效果长期稳定

SEO优化核心服务

网站技术SEO

  • 网站结构优化 - 提升网站爬虫可访问性
  • 页面速度优化 - 缩短加载时间,提高用户体验
  • 移动端适配 - 确保移动设备友好性
  • HTTPS安全协议 - 提升网站安全性与信任度
  • 结构化数据标记 - 增强搜索结果显示效果

内容优化服务

  • 关键词研究与布局 - 精准定位目标关键词
  • 高质量内容创作 - 原创、专业、有价值的内容
  • Meta标签优化 - 提升点击率和相关性
  • 内容更新策略 - 保持网站内容新鲜度
  • 多媒体内容优化 - 图片、视频SEO优化

外链建设策略

  • 高质量外链获取 - 权威网站链接建设
  • 品牌提及监控 - 追踪品牌在线曝光
  • 行业目录提交 - 提升网站基础权威
  • 社交媒体整合 - 增强内容传播力
  • 链接质量分析 - 避免低质量链接风险

SEO服务方案对比

服务项目 基础套餐 标准套餐 高级定制
关键词优化数量 10-20个核心词 30-50个核心词+长尾词 80-150个全方位覆盖
内容优化 基础页面优化 全站内容优化+每月5篇原创 个性化内容策略+每月15篇原创
技术SEO 基本技术检查 全面技术优化+移动适配 深度技术重构+性能优化
外链建设 每月5-10条 每月20-30条高质量外链 每月50+条多渠道外链
数据报告 月度基础报告 双周详细报告+分析 每周深度报告+策略调整
效果保障 3-6个月见效 2-4个月见效 1-3个月快速见效

SEO优化实施流程

我们的SEO优化服务遵循科学严谨的流程,确保每一步都基于数据分析和行业最佳实践:

1

网站诊断分析

全面检测网站技术问题、内容质量、竞争对手情况,制定个性化优化方案。

2

关键词策略制定

基于用户搜索意图和商业目标,制定全面的关键词矩阵和布局策略。

3

技术优化实施

解决网站技术问题,优化网站结构,提升页面速度和移动端体验。

4

内容优化建设

创作高质量原创内容,优化现有页面,建立内容更新机制。

5

外链建设推广

获取高质量外部链接,建立品牌在线影响力,提升网站权威度。

6

数据监控调整

持续监控排名、流量和转化数据,根据效果调整优化策略。

SEO优化常见问题

SEO优化一般需要多长时间才能看到效果?
SEO是一个渐进的过程,通常需要3-6个月才能看到明显效果。具体时间取决于网站现状、竞争程度和优化强度。我们的标准套餐一般在2-4个月内开始显现效果,高级定制方案可能在1-3个月内就能看到初步成果。
你们使用白帽SEO技术还是黑帽技术?
我们始终坚持使用白帽SEO技术,遵循搜索引擎的官方指南。我们的优化策略注重长期效果和可持续性,绝不使用任何可能导致网站被惩罚的违规手段。作为百度官方合作伙伴,我们承诺提供安全、合规的SEO服务。
SEO优化后效果能持续多久?
通过我们的白帽SEO策略获得的排名和流量具有长期稳定性。一旦网站达到理想排名,只需适当的维护和更新,效果可以持续数年。我们提供优化后维护服务,确保您的网站长期保持竞争优势。
你们提供SEO优化效果保障吗?
我们提供基于数据的SEO效果承诺。根据服务套餐不同,我们承诺在约定时间内将核心关键词优化到指定排名位置,或实现约定的自然流量增长目标。所有承诺都会在服务合同中明确约定,并提供详细的KPI衡量标准。

SEO优化效果数据

基于我们服务的客户数据统计,平均优化效果如下:

+85%
自然搜索流量提升
+120%
关键词排名数量
+60%
网站转化率提升
3-6月
平均见效周期

行业案例 - 制造业

  • 优化前:日均自然流量120,核心词无排名
  • 优化6个月后:日均自然流量950,15个核心词首页排名
  • 效果提升:流量增长692%,询盘量增加320%

行业案例 - 电商

  • 优化前:月均自然订单50单,转化率1.2%
  • 优化4个月后:月均自然订单210单,转化率2.8%
  • 效果提升:订单增长320%,转化率提升133%

行业案例 - 教育

  • 优化前:月均咨询量35个,主要依赖付费广告
  • 优化5个月后:月均咨询量180个,自然流量占比65%
  • 效果提升:咨询量增长414%,营销成本降低57%

为什么选择我们的SEO服务

专业团队

  • 10年以上SEO经验专家带队
  • 百度、Google认证工程师
  • 内容创作、技术开发、数据分析多领域团队
  • 持续培训保持技术领先

数据驱动

  • 自主研发SEO分析工具
  • 实时排名监控系统
  • 竞争对手深度分析
  • 效果可视化报告

透明合作

  • 清晰的服务内容和价格
  • 定期进展汇报和沟通
  • 效果数据实时可查
  • 灵活的合同条款

我们的SEO服务理念

我们坚信,真正的SEO优化不仅仅是追求排名,而是通过提供优质内容、优化用户体验、建立网站权威,最终实现可持续的业务增长。我们的目标是与客户建立长期合作关系,共同成长。

提交需求或反馈

Demand feedback