[SERVER-49343] logical find operators: $or, $and, $not, $nor... return matching field count for sort Created: 07/Jul/20 Updated: 27/Oct/23 Resolved: 21/Sep/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 4.4.0-rc12 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Trivial - P5 |
| Reporter: | Andrew Hodel | Assignee: | Katya Kamenieva |
| Resolution: | Community Answered | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Sprint: | Query 2020-09-21, Query 2020-10-05 |
| Participants: |
| Description |
|
I find the text search inadequate at times when splitting the search by word and performing an $or per field with a regex is much more useful.
Would it be possible to add an indicator to each result that counts the number of field matches so that I can sort by relevance within mongodb rather than having to parse through the results after the find()?
Will you, it's a much improved search offering for your product. |
| Comments |
| Comment by Katya Kamenieva [ 21/Sep/20 ] | ||||||||||||||||||||||
|
andrewhodel@gmail.com Thank you for your feedback. Currently there is no plan so support the requested functionality. Feel free to start conversation on the Community forum if you want to discuss more | ||||||||||||||||||||||
| Comment by Andrew Hodel [ 20/Sep/20 ] | ||||||||||||||||||||||
|
That will work, it is odd that there is not a flagged option that simply The way this is built I will have to do another comparison loop to relate It will work though. On Sat, Sep 19, 2020 at 6:02 PM Katya Kamenieva (Jira) <jira@mongodb.org> | ||||||||||||||||||||||
| Comment by Katya Kamenieva [ 20/Sep/20 ] | ||||||||||||||||||||||
|
Hi andrewhodel@gmail.com, I don't think I understand what do you mean by "I am asking for matches per field counts". Please provide example of the input documents, and the result of the query that you are looking for. What I wanted to illustrate is that for data like this:
And query like this, with the $regexFindAll and $size in projection:
The output tells that the word "happy" was found one time for the "title" field of the first document, and two times for the second document.
| ||||||||||||||||||||||
| Comment by Andrew Hodel [ 19/Sep/20 ] | ||||||||||||||||||||||
|
No, this is about returning counts per field. I know how to perform the search. I am asking for matches per field counts On Fri, Sep 18, 2020 at 6:31 PM Katya Kamenieva (Jira) <jira@mongodb.org> | ||||||||||||||||||||||
| Comment by Katya Kamenieva [ 18/Sep/20 ] | ||||||||||||||||||||||
|
andrewhodel@gmail.com, if I understood your question correctly, here is example how you could do this using $regexFindAll in version 4.2 and above.
Does this help? | ||||||||||||||||||||||
| Comment by Andrew Hodel [ 18/Aug/20 ] | ||||||||||||||||||||||
|
Sure.
You just search on many fields using a regex per word (or letter if you are that way).
Then you need to get back a counter per field that shows how many matches there were for each field.
The problem with the text search is that it is not capable of searching many fields. I have used it, it is inadequate. | ||||||||||||||||||||||
| Comment by Katya Kamenieva [ 17/Aug/20 ] | ||||||||||||||||||||||
|
Hi andrewhodel@gmail.com, do you use MongoDB text search and text indexes or is this regarding the Atlas Search? Could you provide an example for the search query and regex that you are referring to? Thank you |