searchlogic

Best way to implement simple sorting / searching in Rails

What's the best way to implement an interface that looks like this in rails? Currently I'm using Searchlogic, and it's a tad painful. Problems include: Making sure certain operations remain orthogonal -- for example, if you select "Short Posts" and then search, your search results should be restricted to short posts. Making sure the...

Full Text Searching with Rails

Hi all, I've been looking into searching plugins/gems for Rails. Most of the articles compare Ferret (Lucene) to Ultrasphinx or possibly Thinking Sphinx, but none that talk about SearchLogic. Does anyone have any clues as to how that one compares? What do you use, and how does it perform? ...

Rails/AR find where habtm does not include

I have a Rails app with Users, and each user HABTM Roles. I want to select Users without a specific role. I have searchlogic at my disposal, and I'm lost. I've tried using a combination of conditions and joins and includes and what not, but I can't seem to nail it. This works: User.find(:all, :conditions => ['role_id != ?', Role[:admin...

SearchLogic + STI

Trying to implement a search logic search that uses associations with STI but I’m having a problem where it is not select the STI records as the subclass but the parent. Example: class Users end class Artist < User has many :agents, :through => :agents artists end class Agent < User has many :artists, :through => :agents artists...

Combine two named scopes with OR (instead of AND)

I want to find all Annotations whose bodies are either: Equal to "?" or Like "[?]" What's the best way to do this? I would like to use SearchLogic if possible, but though SearchLogic allows you to do each of the following: Annotation.body_equals('?') Annotation.body_like('[?]') and you can always chain them together: Annotation....

Single query for all records having no key in a join table and those having a matching key

I have a trip that has many residencies. I need a single query that returns all trips where no residency information has been specified. And all trips that match a specified residency. I can get the first from this query: SELECT * FROM `trips` WHERE (((NOT EXISTS (SELECT id FROM residencies WHERE trips.id = residencies.trip_id)) Bu...

Using searchlogic with will_paginate

EDIT Looks like I figured it out - I had to call paginate after the call to all from Searchlogic. I'm trying to use both of these tools to enable users to search contacts and return a paginated list (or the entire paginated list if they don't enter any search criteria). However I'm unsure of the proper way to chain them together, and w...

Using Searchlogic with multiple models from one controller

How exactly do I use Searchlogic with multiple models? I have a dashboard that pulls data from 3 models and displays them in a grid (table) - I want to allow sorting and searching for all three of these, but Searchlogic seems to demand that I use "search" as the parameter name; doing something like: @users_search = User.search(params[:...

searchlogic with globalize2?

Given there is a model: class MenuItem < ActiveRecord::Base translates :title end and searchlogic is plugged in, I'd expect the following to work: >> MenuItem.search(:title_like => 'tea') Sadly, it doesn't: Searchlogic::Search::UnknownConditionError: The title_like is not a valid condition. You may only use conditions that map t...

Rails: searchlogic search with or conditions

Hello, I'm using the 'binarylogic-searchlogic' gem in version 2.3.5 along with Rails 2.3.4. What I want to do is performing a search on a model for a specified value over multiple attributes. I achieve this through chaining everything together like User.first_name_or_last_name_or_email_like(value) But with more and more attributes ...

Date conditions using Search logic

The Rails plugin - Searchlogic, from binary logic - offers the ability to filter by date. I have my form set up like so... <% form_for @search do |f| %> <%= f.label :start %> <%= f.select :due_at_after, [[['','']],['November', '2009-11-01'.to_date],['December', '2009-12-01'.to_date]] %><br> <%= f.label :end %> <%= f.select :du...

searchlogic parameterized_field_equals? rails

Because Shoe.color_equals('Dark Brown') != Shoe.color_equals('dark-brown') Is there a way to do something like: Shoe.parameterized_color_equals('dark-brown') Not that the api has to be exactly that, but is there a way to accomplish what I've outlined with searchlogic? edit I'll send in the GET params: dark-brown but want to match...

Trouble getting basic searchlogic plugin code to work in Rails App

To preface this I am a complete Rails newcomer so don't judge my lack of skills too harshly. Anyway, my rails app is throwing this error: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id I am trying to make a basic form that will allow a user to search for a "match" by "country". It ...

Searchlogic doesn't convert the time properly for datetime conditions

The author of Searchlogic says that it is delegated to A::R converter, but at least in our case this didn't cover the usual cases. Local time was 'interpreted' as UTC and therefore was moved by one hour (CET). How can I do that properly? I add our current workaround as an answer, hopefully it helps somebody! ...

Reusing named_scope to define another named_scope

The problem essence as I see it One day, if I'm not mistaken, I have seen an example of reusing a named_scope to define another named_scope. Something like this (can't remember the exact syntax, but that's exactly my question): named_scope :billable, :conditions => ... named_scope :billable_by_tom, :conditions => { :billable => tru...

Rails and Searchlogic: finding products that matching all given product categories by using searchlogic condition

I have a model Publication and a model Category in my Rails app. Both are connected with a has_and_belongs_to_many association. Now I would like to search publications that match one or more categories. If more than one category is given they have all assigned to the publication. I want to specify the categories in a multiple select_bo...

What is the difference between searchlogic and other fulltext search plugins?

I am looking for an alternative to acts_as_solr or thinkingsphinx for fulltext search in my Rails app. Came across searchlogic. Does it support indexing? I am planning to host my app on heroku and I want an alternative because heroku charges for Websolr. I am aware of the alternative way of using texticle or acts_as_tsearch but i want t...

Searchlogic cannot sort search result

Imagine a code: search = Project.search( :title_or_description_or_child_name_or_child_age_or_inspiration_or_decorating_style_or_favorite_item_or_others_like_any => keys, :galleries_id_like_any => @g, :styles_id_like_any => @st, :tags_like_any => @t ) search.all returns the rows correctly. But search.descend_by_views returns n...

Search by price interval in currency and other params using Searchlogic

Hi I need to reaqlize search in product model with prices in different currencies (price and currecny_id field). Every currency have own rate. When user search for product in price range [x, y] USD, range must be converted to all currencies and return values like (price > from_eur AND price < to_eur AND currecny_id = 1) OR (price > fr...

How do I set default search conditions with Searchlogic?

I've got a search form on this page: http://staging-checkpointtracker.aptanacloud.com/events If you select a State from the dropdown you get zero results because you didn't select one or more Event Division (checkboxes). What I want is to default the checkboxes to "checked" when the page first loads...to display Events in all Division...