Convert rails named scoped to Solr's filter queries
Rodrigo Souto
rodrigo at colivre.coop.br
Wed Oct 9 13:31:04 BRT 2013
Hey Braulio,
Please open a merge-request that it'll soon be reviewed since this is
a bugfix.
daniel tygel escreveu isso ai:
> One point about this code: This is critic for Cirandas, that uses SOLR.
>
> After the plugin migration, the SOLR searches stopped working in the
> profiles for the systems that use SOLR. So for us, this is much more than
> a feature, it's a fix of a bug which emerged after it was decided to turn
> SOLR into a plugin.
>
> Thank you,
>
> daniel
>
> Em 08-10-2013 13:43, Bráulio Bhavamitra escreveu:
>
> Hello all,
> A common problem when using a search engine like solr togheter with a
> SQL database is to reuse or scope (with rails' scopes) SQL queries.
> As Noosfero generalizes the search engine, being solr one of them, and
> rails' scopes is "filter language", I've made a code to translate
> named_scopes into solr's filter_queries.
> It works by using [1]current_scoped_methods when possible, that is, when
> the scope involved didn't used SQL directly, and when that is the case,
> it requires the field the be indexed on solr.
> The code requires a named_scope monkey patch. Currently, it probably
> only works on rails 2.
> [2]https://github.com/brauliobo/noosfero-ecosol/blob/ai2831/plugins/solr/lib/solr_plugin.rb#L36
> [3]https://github.com/brauliobo/noosfero-ecosol/blob/ai2831/vendor/plugins/monkey_patches/named_scope_with_applied_names/init.rb
> cheers,
> bráulio
>
> ---------- Forwarded message ----------
> From: Bráulio Bhavamitra <[4]brauliobo at gmail.com>
> Date: Mon, Oct 7, 2013 at 4:12 PM
> Subject: [sunspot] Apply ActiveRecord's scope to sunspot queries
> To: [5]ruby-sunspot at googlegroups.com
> Cc: Daniel Tygel <[6]dtygel at eita.org.br>
>
> Hello all,
> Is there any current or planned support for Arel's methods and scopes
> translated into the sunspot solr queries?
> This would make possible to use some existing scopes with sunspot/solr.
> regards,
> bráulio
> --
> You received this message because you are subscribed to the Google
> Groups "Sunspot" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [7]ruby-sunspot+unsubscribe at googlegroups.com.
> To post to this group, send email to [8]ruby-sunspot at googlegroups.com.
> Visit this group at [9]http://groups.google.com/group/ruby-sunspot.
> For more options, visit [10]https://groups.google.com/groups/opt_out.
>
> --
> "Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
> ideologia. Morra por sua ideologia" P.R. Sarkar
>
> EITA - Educação, Informação e Tecnologias para Autogestão
> [11]http://cirandas.net/brauliobo
> [12]http://eita.org.br
>
> "Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é meu
> lar e todos nós somos cidadãos deste cosmo. Este universo é a imaginação
> da Mente Macrocósmica, e todas as entidades estão sendo criadas,
> preservadas e destruídas nas fases de extroversão e introversão do fluxo
> imaginativo cósmico. No âmbito pessoal, quando uma pessoa imagina algo
> em sua mente, naquele momento, essa pessoa é a única proprietária
> daquilo que ela imagina, e ninguém mais. Quando um ser humano criado
> mentalmente caminha por um milharal também imaginado, a pessoa imaginada
> não é a propriedade desse milharal, pois ele pertence ao indivíduo que o
> está imaginando. Este universo foi criado na imaginação de Brahma, a
> Entidade Suprema, por isso a propriedade deste universo é de Brahma, e
> não dos microcosmos que também foram criados pela imaginação de Brahma.
> Nenhuma propriedade deste mundo, mutável ou imutável, pertence a um
> indivíduo em particular; tudo é o patrimônio comum de todos."
> Restante do texto
> em [13]http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia
>
> _______________________________________________
> Noosfero-dev mailing list
> [14]Noosfero-dev at listas.softwarelivre.org
> [15]http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/noosfero-dev
>
> --
> (_.-~*´¨¯¨`*·~-.,-( •_•)-,.-~*´¨¯¨`*·~-._)
> .
> ,-. . |- ,-. Educação,
> |-' | | ,-| Informação e
> `-' ' `' `-^ Tecnologia para
> [16]http://eita.org.br Autogestão
>
> (_.-~*´¨¯¨`*·~-.,-( •_•)-,.-~*´¨¯¨`*·~-._)
>
> References
>
> Visible links
> 1. http://apidock.com/rails/ActiveRecord/Base/current_scoped_methods/class
> 2. https://github.com/brauliobo/noosfero-ecosol/blob/ai2831/plugins/solr/lib/solr_plugin.rb#L36
> 3. https://github.com/brauliobo/noosfero-ecosol/blob/ai2831/vendor/plugins/monkey_patches/named_scope_with_applied_names/init.rb
> 4. mailto:brauliobo at gmail.com
> 5. mailto:ruby-sunspot at googlegroups.com
> 6. mailto:dtygel at eita.org.br
> 7. mailto:ruby-sunspot%2Bunsubscribe at googlegroups.com
> 8. mailto:ruby-sunspot at googlegroups.com
> 9. http://groups.google.com/group/ruby-sunspot
> 10. https://groups.google.com/groups/opt_out
> 11. http://cirandas.net/brauliobo
> 12. http://eita.org.br/
> 13. http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia
> 14. mailto:Noosfero-dev at listas.softwarelivre.org
> 15. http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/noosfero-dev
> 16. http://eita.org.br/
> _______________________________________________
> Noosfero-dev mailing list
> Noosfero-dev at listas.softwarelivre.org
> http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/noosfero-dev
--
Rodrigo Souto <rodrigo at colivre.coop.br> :: 55 71 8131-7714
Colivre - Cooperativa de Tecnologias Livres
http://www.colivre.coop.br/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20131009/8dc86615/attachment.pgp>
More information about the Noosfero-dev
mailing list