Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra unwanted backslash in Morphia Query object #1453

Closed
sahar922 opened this issue Jun 9, 2020 · 2 comments
Closed

Extra unwanted backslash in Morphia Query object #1453

sahar922 opened this issue Jun 9, 2020 · 2 comments
Labels

Comments

@sahar922
Copy link

sahar922 commented Jun 9, 2020

I'm using Morphia 1.5.8 (Java 8) MongoDB (V4.x), trying to use Search for a phrase, so my code looks like :

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

Debug looks good, but in running time the query is being sent with the three backslashes instead of just one, and the query return 0 results.

What am I missing? thanks!

actual generated query: "$text" : { "$search" : "\\\"filteredText\\\"" }

Steps to reproduce the behavior:

  1. Create a TEXT index
  2. Try search by text with \" prefix and suffix
  3. execute

Expected behavior
The query should be \"filteredText\"
** Please complete the following information: **

  • Server Version: 4.X
  • Morphia Version: 1.5.8
@sahar922 sahar922 added the bug label Jun 9, 2020
@evanchooly
Copy link
Member

try this:

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

Though i have to ask, are you searching for that text wrapped in quotes? i.e. are you trying to find "something" or just something? If it's the latter then you can simply pass textToFilter to search().

@evanchooly evanchooly added question and removed bug labels Jun 9, 2020
@sahar922
Copy link
Author

Thanks @evanchooly , can't believe I missed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants