Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional Indexing #33

Closed
jon-n opened this issue Jun 16, 2011 · 11 comments
Closed

Conditional Indexing #33

jon-n opened this issue Jun 16, 2011 · 11 comments

Comments

@jon-n
Copy link

jon-n commented Jun 16, 2011

With tanker, is there a way to make it so that a model is only indexed based on certain conditions? In my case, I only want to index if the model joins to another model. I've tried some different approaches, but so far nothing has been compatible with rake tanker:reindex.

@kidpollo
Copy link
Owner

yeah this is one of the main requests. something like a where statement, I will try to come up with a way. Any suggestions on how te api would look¿?

@jon-n
Copy link
Author

jon-n commented Jun 17, 2011

Yeah, something like a where statement, not sure exactly what's the best way. I was hoping there would be a way to just put some conditions around the "indexes" parts inside the tankit statement

@coryschires
Copy link
Contributor

I would also like the the ability to specify different indexes depending on Rails.env. Currently I have a yaml file which I've sourced in tanker.rb to conditionally set the index name depending on environment. It works fine, but it sorta sucks that I need both a yaml file and an initialization file.

Maybe tanker.rb could be smarter. With commented code snippets and corresponding documentation explaining different configuration options (e.g. pagination). I'm thinking something similar to simple_form.

Either way, it would be really nice if I could easily say: "Use this index in production. Use this index in staging. And so on."

@jon-n
Copy link
Author

jon-n commented Jul 5, 2011

@coryshires not sure if this makes it any better than your yaml setup, but here's how I have my configs set up so tanker uses the appropriate index depending on environment:

app/config/environments/development.rb:

config.indextank_index = 'development_index_name'

app/config/environments/production.rb:

config.indextank_index = 'production_index_name'

And then in the tankit part of in model, I just have:

tankit Rails.configuration.indextank_index do
(tanker stuff)
end

@kidpollo
Copy link
Owner

kidpollo commented Jul 6, 2011

I am actually of the idea that YML files suck and that there is no reason to have credentials embebed in your ruby files loaded in the config directory. Rails already supports loading different config files depending in the environment or if you want a single file just have logic that uses the Rails.env call. I really want tanker to not be super tied to rails. I do have a railtie that can be extended so feel free to submit a patch I will consider it for sure.

@coryschires
Copy link
Contributor

@kidpollo

I'm fine with no yaml files. I actually think athst's suggestion will address my concerns.

Once I merge it into my project (and ensure it works, tho I don't see why it wouldn't), I'll probably update the read me to let others know the best way to set conditional indexes.

@kidpollo
Copy link
Owner

cool! I am finishing adding support for categories! I am exited for the new features of the gem

@timbauman
Copy link

FYI - I am still interested in this feature.

I think the API could be pretty simple--i.e.:

tanker :index do
  indexes :title
  indexes :author
  conditions do
    published
  end
end

Then, if published is true for a particular instance, it will get indexed. If it is false, it will not get indexed.

@kidpollo
Copy link
Owner

Still working hard on this, sorry for the delay!

vvgomes pushed a commit to herval/tanker that referenced this issue Apr 18, 2012
vvgomes pushed a commit to herval/tanker that referenced this issue Apr 18, 2012
vvgomes pushed a commit to herval/tanker that referenced this issue Apr 18, 2012
vvgomes pushed a commit to herval/tanker that referenced this issue Apr 18, 2012
@herval
Copy link
Contributor

herval commented Apr 19, 2012

Here's our pull proposal (mine and @vvgomes): #60

@kidpollo
Copy link
Owner

Implemented :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants