package com.ycl.utils; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.TextCriteria; import org.springframework.util.StringUtils; import java.lang.reflect.Field; import java.util.Date; import java.util.Objects; /** * mongo工具类 * * @author:xp * @date:2024/8/2 15:18 */ public class MongoUtil { /** * 构造全文索引的条件 * * @param query * @param keyword */ public static void fullText(Query query, String keyword) { if (StringUtils.hasText(keyword)) { TextCriteria criteria = TextCriteria.forDefaultLanguage().matching(keyword); query.addCriteria(criteria); } } }