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 8287401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:01:42+00:00 2026-06-08T12:01:42+00:00

While reading the Tire doc, I was under the impression that you should use

  • 0

While reading the Tire doc, I was under the impression that you should use either mapping or to_indexed_json methods, since (my understanding was..) the mapping is used to feed the to_indexed_json.

The problem is, that I found some tutorials where both are used. WHY?

Basically, my app works right now with the to_indexed_json but I can’t figure out how to set the boost value of some of the attributes (hence the reason I started looking at mapping) and I was wondering if using both would create some conflicts.

  • 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-08T12:01:47+00:00Added an answer on June 8, 2026 at 12:01 pm

    While the mapping and to_indexed_json methods are related, they serve two different purposes, in fact.

    The purpose of the mapping method is to define mapping for the document properties within an index. You may want to define certain property as “not_analyzed”, so it is not broken into tokens, or set a specific analyzer for the property, or (as you mention) indexing time boost factor. You may also define multifield property, custom formats for date types, etc.

    This mapping is then used eg. when Tire automatically creates an index for your model.

    The purpose of the to_indexed_json method is to define a JSON serialization for your documents/models.

    The default to_indexed_json method does use your mapping definition, to use only properties defined in the mapping — on a basis that if you care enough to define the mapping, by default Tire indexes only properties with defined mapping.

    Now, when you want a tight grip on how your model is in fact serialized into JSON for elasticsearch, you just define your own to_indexed_json methods (as the README instructs).

    This custom MyModel#to_indexed_method usually does not care about mapping definition, and builds the JSON serialization from scratch (by leveraging ActiveRecord’s to_json, using a JSON builder such as jbuilder, or just building a plain old Hash and calling Hash#to_json).

    So, to answer the last part of your question, using both mapping and to_indexed_json will absolutely not create any conflicts, and is in fact required to use advanced features in elasticsearch.

    To sum up:

    1. You use the mapping method to define the mapping for your models for the search engine
    2. You use a custom to_indexed_json method to define how the search engine sees your documents/models.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While reading this class BitmapFactory I noticed that almost all methods inside are static.
While reading cocoa tutorials i've noticed that some of the tutorials use AppDelegate and
While reading the K&R 2nd edition I noticed that the programs always began with
While reading from a site a read that you can not make a global
While reading documentation on some library, I saw that some library have some feature,
While reading code I see that: vector<TypeA>(typeAObj).swap(typeAObj); My question is Why do they swap
While reading answers to this question I noticed that answers ( this for example)
While reading a book called Let us C I read that a function showbit()
While reading this article, I got a doubt. I understood that while trasferring small
While reading http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html , I found that the caching algorithm is more complex than

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.