Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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 mongo db中的条件匹配操作_Mongodb_Spring Boot_Spring Data Jpa_Aggregation Framework_Spring Data Mongodb - Fatal编程技术网

Mongodb spring mongo db中的条件匹配操作

Mongodb spring mongo db中的条件匹配操作,mongodb,spring-boot,spring-data-jpa,aggregation-framework,spring-data-mongodb,Mongodb,Spring Boot,Spring Data Jpa,Aggregation Framework,Spring Data Mongodb,我使用下面的匹配操作来匹配Spring数据Mongodb中的某些条件 MatchOperation propertyMatchOperation = Aggregation.match( Criteria. where("abc1").is(abcVal1) .and("abc2").is(abcVal2) .and("abc3").is(abcVal3)

我使用下面的匹配操作来匹配Spring数据Mongodb中的某些条件

MatchOperation propertyMatchOperation = Aggregation.match(
    Criteria.
            where("abc1").is(abcVal1)
            .and("abc2").is(abcVal2)
            .and("abc3").is(abcVal3)
            .and("abc4").is(abcVal4)
            .and("abc5").is(abcVal5)
);
当某个值为
null
”时,它会检查mongodb中的
值,而该参数不应包含在查询中

假设,
abcVal3
null
,则上述匹配操作将只搜索参数中的
null
值,并发送零结果,即使其他条件正在匹配


有没有办法让它成为有条件的独占或包含?

我认为匹配不会有问题。如果
abc3
null
,其他4个变量满足您的条件(因为
),它将返回匹配的数据,如“abc1:“first”,“abc2:“second”,“abc3:“third”,“abc4:”“abc5:”。所以,如果我必须把马赫数设为第一,第二,第三,不管abc4和abc5的值是多少,这是不会发生的。它用值“”查询abc4和abc4,这是否意味着您发送了
abc1=“first”
abc2=“second”
abc3=“third”
abc4=null
abc5=null
?或者您正在为
null
发送
?是,因为默认vault值将为null或“”。