Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7932105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:54:59+00:00 2026-06-03T20:54:59+00:00

I have a query criteria which looks for an array of elements ( tags_array

  • 0

I have a query criteria which looks for an array of elements ( tags_array ) to match :

User.all_in('watchlists.tags_array' => tags_array)

I’d like the criteria to be CASE-INSENSITIVE, meaning I want it match %w[Ruby Web Framework] as well as %w[RUBY WEB FRAMEWORK] or %w[ruby web framework] and so on …

Is this possible via mongoid or do I have to use external filter tricks ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:55:00+00:00Added an answer on June 3, 2026 at 8:55 pm

    Thanks to the support of Jordan and just for tracking purposes (for myself and others as well), I’ll post the entire solution.

    Yes, Yuriy Goldshtrakh was right, MongoDB still does not support case-insensitive query but MongoID has regex, my only doubt is regarding performance degradation as already said by “mu is too short” but I didn’t check until now … anyway here it is :

     Object.const_set :Competitor, Struct.new(:html_url, :description, :watchers, :forks)
     def self.find_competitors(tags_array)
        competitors = []
        User.all_in('watchlists.tags_array' => tags_array.map{|tag|/^#{tag}/i}).only(:watchlists).each do |u|
         u.watchlists.all_in(:tags_array => tags_array.map{|tag|/^#{tag}/i}).desc(:watchers).each do |wl|
           competitors << Competitor.new(wl.html_url, wl.description, wl.watchers, wl.forks)
         end
        end
        return competitors
     end
    

    No normalization at save/create mongoid level, the tags are saved either upper or lower case.

    Normalization (case-insensitive matching of tags) are realized entirely during the nested quering criteria ( it’s nested because of embedded one to many model ).

    If you have better idea or code, please have a post.

    I’d also thanks Luiz K. for answering, even if I’ll not follow that way: normalization at data level is too restrictive in my view, loosing semantic and elasticity “user” side (who actually is tagging). Anyway could be a good solution for other requirements.

    Many thanks
    Luca G. Soave

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query which looks for jobs where all the hours assigned have
I have the following Hibernate 3.x Criteria Query which I want to convert it
I have a NHibernate criteria, from which I need to get the SQL query.
I have this query: criteria = session.CreateCriteria(typeof (Building)) .CreateAlias(Estate, estate) .SetProjection(Projections.ProjectionList() .Add(Property.ForName(Name), BuildingName) .Add(Property.ForName(estate.Name),
I have a criteria query: Session.CreateCriteria<Sell043Report>() .SetProjection(.ProjectionList() .Add(LambdaProjection.GroupProperty<Sell043Report>(r => r.location)) .Add(LambdaProjection.GroupProperty<Sell043Report>(r => r.agent)) .Add(LambdaProjection.GroupProperty<Sell043Report>(r
I have a relatively simple query joining two tables. The Where criteria can be
I have query table copyQuery which has Soil Condition has one of the columns,
I have query like this : SELECT EXTRACT(MONTH FROM d.mydate) AS synmonth, SUM(apcp) AS
I'm trying to build a Hibernate Criteria query to find entities that have a
I am trying to update several rows in a table which match some criteria

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.