MongoDB查询仅适用于不带引号的情况

3mpgtkmj  于 2022-09-18  发布在  Go
关注(0)|答案(0)|浏览(107)

我在Mongo DB文档中有以下数据,集合OUTHING_COUNTS。

{ "_id" : ObjectId("632158ed6fe76c381114ef71"), "MSISDN" : "0", "tot_out_duration" : 
     NumberLong(46), "num_out" : NumberLong(2), "tot_in_duration" : NumberLong(0), "num_in" : 
     NumberLong(0), "CALL_DATE_HOUR" : "2022091400" }
    { "_id" : ObjectId("632158ed6fe76c381114ef72"), "MSISDN" : "14169364496", 
     "tot_out_duration" : NumberLong(29), "num_out" : NumberLong(1), "tot_in_duration" : 
     NumberLong(0), "num_in" : NumberLong(0), "CALL_DATE_HOUR" : "2022091400" }
     { "_id" : ObjectId("632158ed6fe76c381114ef73"), "MSISDN" : "22393750115", 
      "tot_out_duration" : NumberLong(135), "num_out" : NumberLong(2), "tot_in_duration" : 
      NumberLong(0), "num_in" : NumberLong(0), "CALL_DATE_HOUR" : "2022091400" }
     { "_id" : ObjectId("632158ed6fe76c381114ef74"), "MSISDN" : "2250797667529", 
      "tot_out_duration" : NumberLong(0), "num_out" : NumberLong(0), "tot_in_duration" : 
      NumberLong(2), "num_in" : NumberLong(1), "CALL_DATE_HOUR" : "2022091400" }

使用以下工具查询数据时:

db.outgoing_counts.find({"CALL_DATE_HOUR":/20220914/})

它返回正确的结果。然而,当我们使用这个时:

db.outgoing_counts.find({"CALL_DATE_HOUR":"/20220914/"})

结果集为空。

我使用的是“”,因为从PySpark发送的查询中的参数总是带有引号。有没有一种方法可以不加引号地将参数从PySpark发送到MongoDB,或者也可以使用引号从MongoDB获得正确的结果。

我还尝试了regexMatch和Match函数,但只能在没有引号的情况下工作。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题