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

  • Home
  • SEARCH
  • 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 8871439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:59:38+00:00 2026-06-14T17:59:38+00:00

I’ve a rails app with a full-text search based on Elasticsearch and Tire, it

  • 0

I’ve a rails app with a full-text search based on Elasticsearch and Tire, it is already working on a MongoDB model called Category, but now I want to add a more complex search based on MongoID Embedded 1-n model User which embeds_many :watchlists

Now I have to bulk import and indexing all the field in Watchlist, and I’d like to know :

  1. how can I do that ?
  2. can index just the watchlists children fields, without the user parents fields ?

The Embedded 1-N MongoDB/MongoID model looks like the following :

app/models/user.rb ( the parent ) :

class User
  include Mongoid::Document

  include Tire::Model::Search
  include Tire::Model::Callbacks
  index_name 'users'

  field :nickname
  field ... many others

  embeds_many :watchlists
end

app/models/watchlist.rb ( the embedded “many” childrens ) :

class Watchlist
  include Mongoid::Document

  include Tire::Model::Search
  include Tire::Model::Callbacks
  index_name 'watchlists'

  field :html_url
  embedded_in :user
end

Any suggestion on how to accomplish the task ?

UPDATE:
here it is a chunk of the model seen with mongo shell

    > user = db.users.findOne({'nickname': 'lgs'})
    {
       "_id" : ObjectId("4f76a16cf2a6a12f88cbca43"),
       "encrypted_password" : "",
       "sign_in_count" : 0,
       "provider" : "github",
       "uid" : "1573",
       "name" : "Luca G. Soave",
       "email" : "luca.soave@gmail.com",
       "nickname" : "lgs",
       "watchlists" : [
           {
               "_id" : ObjectId("4f76997f1d41c81173000002"),
               "tags_array" : [ git, peristence ],
               "html_url" : "https://github.com/mojombo/grit",
               "description" : "Grit gives you object oriented read/write access to Git repositories via Ruby.",
               "fork_" : false,
               "forks" : 207,
               "watchers" : 1258,
               "created_at" : ISODate("2007-10-29T14:37:16Z"),
               "pushed_at" : ISODate("2012-01-27T01:05:45Z"),
               "avatar_url" : "https://secure.gravatar.com/avatar/25c7c18223fb42a4c6ae1c8db6f50f9b?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"
           },
       ...
       ...
    } 

I’d like to index & query any fields owned by the embedded child watchlists doc :

 ... "tags_array", "html_url", "description", "forks" 

but I don’t want elasticsearch to include the parent user fields :

 ... "uid", "name", "email", "nickname" 

so that when I query for “git persistence”, it will look into each ‘watchlists’ indexed fields of each ‘user’ of the original MongoDB.

(sorry for mismatching singular and plurals here, I was just indicating the doc object names)

  • 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-14T17:59:40+00:00Added an answer on June 14, 2026 at 5:59 pm

    It really depends on how you want to serialize your data for the search engine, based on how you want to query them. Please update the question and I’ll update the answer. (Also, it’s better to just remove the ES logs, they are not relevant here.)

    I’m not sure how the Rake task works with embedded documents in Mongo, and also why it seems to “hang” at the end. Is your data in the “users” index when you run the task?

    Notice that it’s quite easy to provide your own indexing code, when the Rake task is not flexible enough. See the Tire::Index#import integration tests.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

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.