Skip to content

Loading…

Add a :load option to search methods to load records from database #61

Closed
karmi opened this Issue · 0 comments

1 participant

@karmi
Owner

In the new ActiveModel implementation (in the activerecord branch), there's an option to load the "real", underlying model with the loadmethod. This allows for loading the records only one-by-one, though.

An option :load => true shall be implemented for all the search methods, which will eagerly load all the records from the database (in Results::Tire::Collection#results), based on IDs returned from ElasticSearch.

This will allow to use Tire (and ElasticSearch) to retrieve batches of records at one, when neccessary (eg. in export jobs).

@karmi karmi was assigned
@karmi karmi added a commit that closed this issue
@karmi [ACTIVEMODEL] Added the `:load` option for search to eagerly load mod…
…el instances from the database

In ActiveModel/ActiveRecord implementation, there's an option to load the "real",
underlying model with the `load` method. This allows
for loading the records only one-by-one, though.

An option as `:load => true` for the search methods will eagerly load all the records
from the database (in Results::Tire::Collection#results),
based on IDs returned from ElasticSearch:

    Article.search 'love', :load => true
    => Article.find [1, 2]

Any option other then TrueClass given as `:load` will be passed
to the model's `find` method:

    Article.search 'love', :include => 'comments'
    => Article.find [1, 2], :include => 'comments'

This allows to use Tire (and ElasticSearch) to retrieve batches of records at once,
when needed (eg. in export jobs).

[Closes #61]
ba460a5
@karmi karmi closed this in ba460a5
@karmi karmi added a commit that referenced this issue
@karmi Changed the method arguments parsing in Tire::Model::Search::ClassMet…
…hods#search for more fluid interface

Given changes in tire@ba460a5 (see #61), the interface for block searches with options was demented:

    results = ActiveRecordArticle.search nil, :load => true do
      ...
    end

The new interface is sane:

results = ActiveRecordArticle.search :load => true do
  ...
end
bab36ca
@karmi karmi added a commit that referenced this issue
@karmi Changed the method arguments parsing in Tire::Model::Search::ClassMet…
…hods#search for more fluid interface

Given changes in tire@ba460a5 (see #61), the interface for block searches with options was demented:

    results = ActiveRecordArticle.search nil, :load => true do
      ...
    end

The new interface is sane:

results = ActiveRecordArticle.search :load => true do
  ...
end
ec30291
@karmi karmi added a commit that referenced this issue
@karmi Changed the method arguments parsing in Tire::Model::Search::ClassMet…
…hods#search for more fluid interface

Given changes in tire@ba460a5 (see #61), the interface for block searches with options was demented:

    results = ActiveRecordArticle.search nil, :load => true do
      ...
    end

The new interface is sane:

results = ActiveRecordArticle.search :load => true do
  ...
end
f17dd1f
@johnthethird johnthethird pushed a commit that referenced this issue
@karmi [ACTIVEMODEL] Added the `:load` option for search to eagerly load mod…
…el instances from the database

In ActiveModel/ActiveRecord implementation, there's an option to load the "real",
underlying model with the `load` method. This allows
for loading the records only one-by-one, though.

An option as `:load => true` for the search methods will eagerly load all the records
from the database (in Results::Tire::Collection#results),
based on IDs returned from ElasticSearch:

    Article.search 'love', :load => true
    => Article.find [1, 2]

Any option other then TrueClass given as `:load` will be passed
to the model's `find` method:

    Article.search 'love', :include => 'comments'
    => Article.find [1, 2], :include => 'comments'

This allows to use Tire (and ElasticSearch) to retrieve batches of records at once,
when needed (eg. in export jobs).

[Closes #61]
be41a88
@karmi karmi added a commit that referenced this issue
@karmi Changed the method arguments parsing in Tire::Model::Search::ClassMet…
…hods#search for more fluid interface

Given changes in tire@ba460a5 (see #61), the interface for block searches with options was demented:

    results = ActiveRecordArticle.search nil, :load => true do
      ...
    end

The new interface is sane:

results = ActiveRecordArticle.search :load => true do
  ...
end
6118b5e
@sakrafd sakrafd pushed a commit that referenced this issue
@karmi [ACTIVEMODEL] Added the `:load` option for search to eagerly load mod…
…el instances from the database

In ActiveModel/ActiveRecord implementation, there's an option to load the "real",
underlying model with the `load` method. This allows
for loading the records only one-by-one, though.

An option as `:load => true` for the search methods will eagerly load all the records
from the database (in Results::Tire::Collection#results),
based on IDs returned from ElasticSearch:

    Article.search 'love', :load => true
    => Article.find [1, 2]

Any option other then TrueClass given as `:load` will be passed
to the model's `find` method:

    Article.search 'love', :include => 'comments'
    => Article.find [1, 2], :include => 'comments'

This allows to use Tire (and ElasticSearch) to retrieve batches of records at once,
when needed (eg. in export jobs).

[Closes #61]
1e34cde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.