Giter VIP home page Giter VIP logo

Comments (3)

brunoocasali avatar brunoocasali commented on June 2, 2024

This issue is related to this one: meilisearch/integration-guides#223

from meilisearch-rails.

ellnix avatar ellnix commented on June 2, 2024

This presents a couple of difficulties to implement on ms_reindex! on models, primarily because indexes are not 1:1 mapped to models.

The primary issue is about shared indexes. Since currently we only keep track (and can only keep track) of the indexes on models, reindex! does not in fact know what models are on an index.

For the sake of argument imagine a Movie model and a ShortFilm model which have a shared index with uid "Video".

Attempting to keep track of them with some sort of configuration hash is no good. Models in Rails are lazy-loaded, which means the meilisearch do ... end block may not have run for Movie when we call reindex! on ShortFilm so our gem will be blind to the Movie config and swap the entire index with ShortFilm only. While we can reasonably assume that every model will be loaded in time in a production environment, it would be a nasty surprise to someone opening bin/rails console to do some housekeeping to find that calling reindex! on ShortFilm will remove all Movie entries from the "Video" index.

Attempting to cache this on some sort of persistent configuration would likely be vulnerable to edge case bugs with newly added models or updated meilisearch configurations that have not been cached yet.

The current reindex! method does not have to worry about any of this since it does not remove documents from the index (apart from those that fail the if or unless condition).

From the algoliasearch-rails README on shared indexes:

Notes: If you target a single index from several models, you must never use MyModel.reindex and only use MyModel.reindex!. The reindex method uses a temporary index to perform an atomic reindexing: if you use it, the resulting index will only contain records for the current model because it will not reindex the others.

Essentially, they defer judgement about whether or not to do an index swap or a regular reindex to the user. I am personally not sure if I like that idea, it seems to me like it could cause trouble for users who aren't well versed in the terminology or have so many models that it is not feasible to expect them to be accurate in determining if an index is shared or not.

from meilisearch-rails.

doutatsu avatar doutatsu commented on June 2, 2024

Curious if there has been any movement on this? I would really like to reindex without worry (#263 (comment))

from meilisearch-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.