Git Product home page Git Product logo

Comments (18)

brstp avatar brstp commented on May 15, 2024

+1

from kaminari.

lacco avatar lacco commented on May 15, 2024

+1

from kaminari.

murphyslaw avatar murphyslaw commented on May 15, 2024

+1

from kaminari.

medihack avatar medihack commented on May 15, 2024

+1 ... Sunspot support would be great.

from kaminari.

amatsuda avatar amatsuda commented on May 15, 2024

Thanks for the request and +1s!

Just added an initial implementation of generic Arrayish object support e04f65a.
Can you bundle '>= 0.12.0' gem and try something like this?

Kaminari.paginate_array(search_result).page(params[:page])

I haven't tested with Sunspot myself, but hope this works.

from kaminari.

lacco avatar lacco commented on May 15, 2024

I just tested your code:

MyModel.search do
  keywords(params[:search])
  #paginate(:page => params[:page])
end
Kaminari.paginate_array(result.hits.map(&:result)).page(params[:page])

I works fine, but this way Sunspot can't perform the pagination itself on database level (as far as I see). I would like to leave out the Kaminari::PaginatableArray#page to avoid the offset like this:

MyModel.search do
  keywords(params[:search])
  paginate(:page => params[:page])
end
Kaminari.paginate_array(result.hits.map(&:result))#.page(params[:page])

Now I am getting the following error:
undefined method current_page' for #Kaminari::PaginatableArray:0x00000104a47e78`

I am not sure if I am doing something wrong, or if you have to extend Kaminari?

from kaminari.

tejo avatar tejo commented on May 15, 2024

+1 for sunspot support

from kaminari.

dhiemstra avatar dhiemstra commented on May 15, 2024

+1

from kaminari.

danoph avatar danoph commented on May 15, 2024

+1

from kaminari.

dhiemstra avatar dhiemstra commented on May 15, 2024

Because sunspot handles the pagination I modified the Kaminari paginate helper so it can accept and handle a sunspot search result object. Could someone please test it out in his project before i enter a pull request?
https://github.com/dhiemstra/kaminari/commit/b9e868f737b87d88aa1f81e63a7f71722468f1ce
gem 'kaminari', :git => '[email protected]:dhiemstra/kaminari.git', :branch => :sunspot_support

from kaminari.

medihack avatar medihack commented on May 15, 2024

I wonder that when Sunspot handles the pagination, why we all vote here for integration?! Wouldn't it be better to clean up this pull request and vote there? Or at least open up a Sunspot ticket?

from kaminari.

dhiemstra avatar dhiemstra commented on May 15, 2024

Medihack, the reason is that sunspot handles the pagination of the results but not the actual view helper of the pagination.
For example most of the models of our project is normal AR and pagination goes via kaminari, because we have a search function for 3 models we would have to write our own pagination helper next to kaminari's helper or use will_paginate for those results.
This is duplication and forces you to maintain two views for the pagination of your project.

from kaminari.

lardawge avatar lardawge commented on May 15, 2024

@dhiemstra, Why do you have to write pagination helpers for each model that has a search? In the view all your doing is passing an array to paginate and as long as the specified methods are defined on it, it just works. That is what medihack is referring to and I agree with.

Anyway, here is a pull request I submitted with tests to sunspot. Can you guys test and report your findings? https://github.com/outoftime/sunspot/pull/63

Thanks.
~Larry

from kaminari.

lardawge avatar lardawge commented on May 15, 2024

For anyone looking for a quick and dirty fix until support gets added to sunspot, drop this in config/initializer folder:
https://gist.github.com/1045196

Also, test and +1 to the pull request here:
https://github.com/outoftime/sunspot/pull/64

~Larry

from kaminari.

dhiemstra avatar dhiemstra commented on May 15, 2024

Thanks lardawge!

from kaminari.

lardawge avatar lardawge commented on May 15, 2024

Kaminari support added to Sunspot here: outoftime/sunspot@08dc66b

Please test so we can get a release.

from kaminari.

dmitry-a-l avatar dmitry-a-l commented on May 15, 2024

it works

from kaminari.

yuki24 avatar yuki24 commented on May 15, 2024

It looks like Sunspot has support for generic pagination and there is no additional implementation needed on kaminari-side. Thanks @lardawge for your great work!
Open this issue again if there is any problem with sunspot integration.

from kaminari.

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.