从长尾关键词挖掘站长工具智能改写 - 5118营销大数据中获得数据集
```java @Autowired MongoTemplate mongoTemplate;
- /**
- * 联想词
- * @param userSearchDto
- * @return
- */
- @Override
- public ResponseResult findAssociate(UserSearchDto userSearchDto) {
- //1 参数检查
- if(userSearchDto == null || StringUtils.isBlank(userSearchDto.getSearchWords())){
- return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
- }
- //分页检查
- if (userSearchDto.getPageSize() > 20) {
- userSearchDto.setPageSize(20);
- }
-
- //3 执行查询 模糊查询
- Query query = Query.query(Criteria.where("associateWords").regex(".*?\\" + userSearchDto.getSearchWords() + ".*"));
- query.limit(userSearchDto.getPageSize());
- List<ApAssociateWords> wordsList = mongoTemplate.find(query, ApAssociateWords.class);
-
- return ResponseResult.okResult(wordsList);
- }
```