[SERVER-10227] Add regex support to FTS command/queries Created: 16/Jul/13  Updated: 28/Dec/23

Status: Backlog
Project: Core Server
Component/s: Text Search
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Ryan Nitz Assignee: Backlog - Query Integration
Resolution: Unresolved Votes: 3
Labels: qi-text-search
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-14865 Support for Regex in Text Search seco... Closed
Related
is related to SERVER-10413 mongodb Text Search with wild card Backlog
Assigned Teams:
Query Integration
Participants:

 Description   

It would be very useful for querying FTS indexes to support regular expressions in the "search" field/parameter.

If you are indexing and querying non-standard/language text content, there are use cases where you would want to know about substrings.

Using the example content below, it would be nice to be able to say:

firstTest18 AND -someText AND /.*Wrong22$/

Example Content
firstTest18 worked well, but there was an exception of type: SomethingThatVariesWrong22



 Comments   
Comment by J Rassi [ 12/Aug/14 ]

Linking dup SERVER-14865.

The solution Eliot proposes above is clunky in that it requires the user writing the query to know what fields are being indexed. My personal refinement of this feature request would be to support some mechanism to allow users to specify an additional predicate that would be applied to all text-index fields (which would filter for documents that have at least one text-indexed field that passes the predicate).

To illustrate: suppose a user has defined an index {a: "text", b: "text", c: "text"}. In today's query language, to perform the operation that Ryan poses as "firstTest18 AND -someText AND /.*Wrong22$/", the user constructs the following query:

db.collection.find({$text: {$search: "firstTest18 -someText"}, $or: [{a: /.*Wrong22$/}, {b: /.*Wrong22$/}, {c: /.*Wrong22$/}]})

Perhaps a $text sub-operator (perhaps called something like $match) could be introduced such that the following is equivalent to the above:

db.collection.find({$text: {$search: "firstTest18 -someText", $match: /.*Wrong22$/}})

Comment by Eliot Horowitz (Inactive) [ 17/Jul/13 ]

What does using a filter in the command not work?
You should be able to do that now?

db.foo.runCommand( "text" , { search : "firstTest18 -someText", filter :

{ something : /.*Wrong22$/ }

} )

Generated at Thu Feb 08 03:22:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.