DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCMONGODB-129
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Marcin Jurkowski
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store MongoDB

Evaluate expressions invoking basic string methods in-database

Created: 16/Nov/13 02:09 AM   Updated: 19/Nov/13 10:29 AM   Resolved: 17/Nov/13 09:00 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 3.2.5

File Attachments: 1. File 0001-Evaluate-basic-string-predicates-in-database.svn.diff (6 kB)


Forum Thread URL: http://www.datanucleus.org/servlet/forum/viewthread_thread,7624
Datastore: MongoDB


 Description  « Hide
Queries invoking the following string methods: equals(), matches(), startsWith(), endsWith() can be evaluated in-database using $regexp operator provided that:
 1. The method is invoked on a field,
 2. The method's parameter is a parameter expression.

It's worth noting that MongoDB will handle a query with startsWith() efficiently using an index, if one exists.

For substring search, the most efficient way is to use matches() predicate, escaping string literal with Java Pattern.quote(). If a case-insensitive query is desirable, escaped string should be prefixed with "(?i)" regexp modifier.

Even though substring search cannot be speed up by an index, having this evaluated in-database still allows a part of query to use index and prevents in-memory query evaluation.


Sort Order: Ascending order - Click to sort in descending order
Marcin Jurkowski added a comment - 16/Nov/13 02:09 AM
A patch

Andy Jefferson added a comment - 16/Nov/13 08:41 AM
This patch doesn't apply cleanly. Please provide a patch ("diff -u" format) that applies from the root of the "store.mongodb/trunk" project.

Marcin Jurkowski added a comment - 17/Nov/13 12:44 AM
What is the version of your patch utility? I checked this out and the diff applies cleanly using both "patch" with -p1 option (I'm using version 2.6.1) and "svn patch" (ver 1.7.13).

Anyway, I'll attach a diff generated by "svn diff" command but the only difference I see is:
 1. The comment section, which should be ignored anyway,
 2. The path prefix in git generated file which needs to be stripped using -p1 option

Marcin Jurkowski added a comment - 17/Nov/13 12:45 AM
A patch generated with "svn diff" against "store.mongodb/trunk" root

Andy Jefferson added a comment - 17/Nov/13 09:00 AM
SVN trunk has this now. Thanks