SpringData regex not working as expected


Working native query

{ $match: { $and : [ {userType:"200"}, { $or: [ {login : /infosys/}, {email : /infosys/}, {firstName : /infosys/}, {lastName : /infosys/} ] } ] } }

SpringData API which is not working as expected:

match( Criteria.where("userType").is(userType).orOperator( Criteria.where("login").regex(searchTxt).orOperator( Criteria.where("email").regex(searchTxt).orOperator( Criteria.where("firstName").regex(searchTxt).orOperator(Criteria.where("lastName").regex(searchTxt)) ) ) ) );


You are $or each criteria with the $or operator. orOperator takes a list of crtieria.

Below is the equivalent for your native query.

match ( Criteria.where("userType").is(userType) .orOperator( Criteria.where("login").regex(searchTxt), Criteria.where("email").regex(searchTxt), Criteria.where("firstName").regex(searchTxt), Criteria.where("lastName").regex(searchTxt) ) )


  • Sequelize joining two tables which are not associated
  • Error on Wordpress Admin URL after moving from localhost to remote
  • LINQ to Entities does not recognize the method 'System.Collections.Generic.Dictionary`2[System.
  • When use gae remote error occured : com.google.appengine.repackaged.com.google.api.client.http.HttpR
  • Sails.js API passport.js authentication
  • Android application not restoring state when installed from .apk, works fine from eclipse
  • Express JS Display Data By ID
  • Kivy, TypeError: 'NoneType' object has no attribute '__getitem__'
  • Meteor.. accounts- password— Create account on client without login
  • Get current user from inside the model in Sails
  • Strong vs Weak entities MYSQL
  • ASP.NET windows authentication should always ask for credentials
  • Is it better to have roles as a column on my users table, or do it through join tables (Roles &
  • read values from form post in jquery or javascript
  • Embedded Glassfish JPA Datasource connection fail
  • (Tcl/Expect) clear screen after exit
  • How do I access an unhandled exception in an MVC Error view?
  • Custom Tabgroup Appcelerator
  • How to attach a node.js readable stream to a Sendgrid email?
  • Email verification using google app script and google forms
  • Bad request using file_get_contents for PUT request in PHP
  • Django rest serializer Breaks when data exists
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • Disable Enter in editText android
  • why do I get the error when installing the gem 'pg'? [duplicate]
  • Recording logins for password protected directories
  • Email format validation in mvc3 view
  • Is there any way to access browser form field suggestions from JavaScript?
  • Dynamically accessing properties of knockoutjs observable array
  • sending/ receiving email in Java
  • Hazelcast - OperationTimeoutException
  • Display Images one by one with next and previous functionality
  • RestKit - RKRequestDelegate does not exist
  • Revoking OAuth Access Token Results in 404 Not Found
  • SQL merge duplicate rows and join values that are different
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Getting error when using KSoap library to consume .NET web services
  • Hits per day in Google Big Query
  • File not found error Google Drive API
  • Converting MP3 duration time