[SERVER-55286] $regex operator inside a Spring Boot @Query annotation unsuccessful Created: 18/Mar/21  Updated: 19/Mar/21  Resolved: 19/Mar/21

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Pavel Antonov Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2021-03-18-11-24-43-968.png     PNG File image-2021-03-18-11-38-16-718.png     PNG File image-2021-03-18-11-39-03-720.png     PNG File image-2021-03-18-11-39-20-866.png     PNG File image-2021-03-18-11-39-24-832.png    
Operating System: ALL
Steps To Reproduce:

I would like to retrieve every document with a patchName(String), which contains a given phrase. E.g. "When the user submits a keyword "S2A", he will acquire all matching documents with patch names i.e., "patchName" : "S2A_MSIL2A_20170613T101031_0_64". Since I would like that the phrase is contained into the patch name, I decided to go with $regex, since a text index searches only exact phrases. I managed it to submit the query in the mongodb shell, however, I am not able to reproduce it inside the Spring Boot Repository class at server-side. Hereby I attach some screenshots:

 

And here is the analogous query, submitted from Spring Boot Repository class:

 

And this is how I invoke it (p.s. I tried several approaches, but still nothing):

Whichever approach I take, it still does not work. Even if I submit the exact patch name of the document, it does not retrieve it.

Hereby I provide you with two example documents (the data originates from the BigEarthNet archive (http://bigearth.net/):

{
"_id" : ObjectId("60531c9be17ae9783919549b"),
"type" : "Feature",
"location" : [
[
20.9996003792675,
63.3486882292739
],
[
20.9996003792675,
63.3379164659186
],
[
21.0235688072459,
63.3379164659186
],
[
21.0235688072459,
63.3486882292739
],
[
20.9996003792675,
63.3486882292739
]
],
"properties" :

{ "patchName" : "S2A_MSIL2A_20170613T101031_0_63", "labels" : [ "f" ], "acquisitionDate" : ISODate("2017-01-13T09:10:31Z") }

,
"_class" : "com.tuberlin.dbpro.models.database.MetaJson"
}

{
"_id" : ObjectId("60531c9be17ae9783919549c"),
"type" : "Feature",
"location" : [
[
20.9996005286705,
63.3379184119332
],
[
20.9996005286705,
63.3271466330944
],
[
21.0235599998921,
63.3271466330944
],
[
21.0235599998921,
63.3379184119332
],
[
20.9996005286705,
63.3379184119332
]
],
"properties" :

{ "patchName" : "S2A_MSIL2A_20170613T101031_0_64", "labels" : [ "f" ], "acquisitionDate" : ISODate("2017-01-13T09:10:31Z") }

,
"_class" : "com.tuberlin.dbpro.models.database.MetaJson"
}

 

 

 

 

 

Participants:

 Description   

Hello,

 

I have spent hours trying to successfully submit a $regex driven query using the Java Spring Boot @Query annotation. I also tried with the generated query methods based on names, however, still nothing.

I have already searched in the documentation and throughout the Internet, but I could not identify my mistake. Could anyone back me up on this one?

 

Regards,

Pavel Antonov



 Comments   
Comment by Eric Sedor [ 19/Mar/21 ]

Glad to hear you found the issue paveldushev9@gmail.com, thanks for updating us. In the future, if you're having a problem but don't yet suspect a bug in the MongoDB core server itself, we tend to recommend asking our community for help by posting on the MongoDB Developer Community Forums.

If the discussion there leads you to suspect a bug in the MongoDB server, then we'd want to discuss here in the SERVER project.

Thanks,
Eric

Comment by Pavel Antonov [ 19/Mar/21 ]

There was actually a hidden issue in my back-end. Everything works as expected.

Feel free to delete the ticket.

Sorry for bothering!

Generated at Thu Feb 08 05:36:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.