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

Changing cache path? #146

Open
IanTrudel opened this issue Feb 14, 2017 · 2 comments
Open

Changing cache path? #146

IanTrudel opened this issue Feb 14, 2017 · 2 comments

Comments

@IanTrudel
Copy link

Hello @floere ! How to change the cache path for loading and dumping index?

@floere
Copy link
Owner

floere commented Feb 15, 2017

@backorder Hi Ian! 😊 You can change the general index path by changing Picky.root (default is Dir.pwd). Let me know if that's not what you are looking for – preferably via example code . Thanks!

@IanTrudel
Copy link
Author

Thanks, @floere! It does work. There is however a caveat: Picky.root must be defined before the creation of any Picky::Index. If it is used after, it will dump using the new path but will load from the default path.

require 'picky'

Person = Struct.new :id, :first, :last

Picky.root = File.join(Dir.pwd, "database")

index = Picky::Index.new :people do
  source { People.all }
  indexing splits_text_on: /[\s-]/
  category :first
  category :last
end
index.add Person.new(1, 'Florian', 'Hanke')
index.add Person.new(2, 'Peter', 'Mayer-Miller')

people = Picky::Search.new index do
  searching splits_text_on: /[\s,-]/
end

results = people.search 'Miller'
p results.ids # => [2]

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

2 participants