Tire - Elasticsearch - how to skip indexing on create?
Asked Answered
L

1

8

I' m working on a rails app. using gem tire as a bond for elasticsearch. in a multistep form I would like to index at the end of the procedure.

is there a way of skipping indexing on create.

guess: Post.create( :indexing => false ) or whatever

or in tire config say : only index Post with attribute :published set to true

Hope I made myself clear. thanks in advance for your answers.

Cheers.

Lavabo answered 6/3, 2012 at 16:12 Comment(3)
ok i guess I found out myself... don'tf look at the timestamps please... In the indexed model you can add: after_save do update_index if published == true end Hope it'll help some future lazy folks ok i guess I found out myself... don'tf look at the timestamps please... In the indexed model you can add: after_save do update_index if published == true end Hope it'll help some future lazy folksLavabo
Do not "include Tire::Model::Callbacks" in your model if you use this method (cf. github.com/karmi/tire/issues/486).Kings
@Stan - be sure to write up an answer and mark it as accepted. Nothing wrong with answering your own question!Lotti
C
0

re: your answer above, after_save is called on create too so a better, more general answer to your question (i think) would be to make sure not to include Tire::Model::Callbacks in your model then

after_create :my_callback

def my_callback
  false
end
Chadwell answered 3/4, 2013 at 22:46 Comment(1)
just be careful here because after_save fires on create too, so if you're using that you'll have to figure out a way to make sure it doesn't fire on create as well.Chadwell

© 2022 - 2024 — McMap. All rights reserved.