Morphia查询对象中多余的反斜杠

问题描述 投票:0回答:1

[我正在使用Morphia 1.5.2(Java 8)作为MongoDB(V4.x)的驱动程序,试图使用Search for a phrase,所以我的代码如下所示:

datastore.find(myEntity).disableValidation().search("\\\"" + textToFilter + "\\\"");

调试看起来不错,但是在运行时,查询发送时带有三个反斜杠而不是一个反斜杠,并且查询返回0个结果。

我想念的是什么?谢谢!

实际生成的查询:"$text" : { "$search" : "\\\"filteredText\\\"" }

java mongodb character-encoding morphia
1个回答
0
投票
datastore.find(myEntity).disableValidation().search("\"" + textToFilter + "\"");

感谢@evanchooly!

© www.soinside.com 2019 - 2024. All rights reserved.