What to do with missing fields in sunspot-rails?

Posted by chrismealy on Stack Overflow See other posts from Stack Overflow or by chrismealy
Published on 2012-06-06T22:37:33Z Indexed on 2012/06/06 22:40 UTC
Read the original article Hit count: 198

I'm using sunspot/rails version 2. It's working great, but I can't figure out how to handle missing fields. If I don't have latitude and longitude this code will map it to 0,0 (near Africa):

searchable do
  text      :resume, :stored => true
  text      :city, :boost => 5
  latlon(:geo) { Sunspot::Util::Coordinates.new(latitude, longitude) }
end

I tried using two search blocks, each with a different conditional, but sunspot just uses the first searchable block. What I want to happen is for things missing locations to still be searchable, just not by location.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about sunspot

  • Can't connect to Sunspot server in Ubuntu server

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I followed the steps in https://github.com/outoftime/sunspot/wiki/Adding-Sunspot-search-to-Rails-in-5-minutes-or-less to install & set up Sunspot search in Rails in a Mac OS and it is ok. In a Ubuntu server, there's connection refused error. When I run rake sunspot:solr:start and the proccess… >>> More

  • RSolr RequestError Solr Response Severe errors in solr configuration

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I was reindexing my model when I suddenly shutdown my mac, When I try to reindex again using (Model_name).reindex in script/console I encountered an error that I haven't encountered before. RSolr::RequestError: Solr Response: Severe_errors_in_solr_configuration__Check_your_log_files_for_more_detailed_information_on_what_may_be_wrong__If_you_want_solr_to_continue_after_configuration_errors_change____abortOnConfigurationErrorfalseabortOnConfigurationError__in_null___javalangRuntimeException_javaioIOException_read_past_EOF__at_orgapachesolrcoreSolrCoregetSearcherSolrCorejava1068__at_orgapachesolrcoreSolrCoreinitSolrCorejava579__at_orgapachesolrcoreCoreContainer$InitializerinitializeCoreContainerjava137__at_orgapachesolrservletSolrDispatchFilterinitSolrDispatchFilterjava83__at_orgmortbayjettyservletFilterHolderdoStartFilterHolderjava99__at_orgmortbaycomponentAbstractLifeCyclestartAbstractLifeCyclejava40__at_orgmortbayjettyservletServletHandlerinitializeServletHandlerjava594__at_orgmortbayjettyservletContextstartContextContextjava139__at_orgmortbayjettywebappWebAppContextstartContextWebAppContextjava1218__at_orgmortbayjettyhandlerContextHandlerdoStartContextHandlerjava500__at_orgmortbayjettywebappWebAppContextdoStartWebAppContextjava448__at_orgmortbaycomponentAbstractLifeCyclestartAbstractLifeCyclejava40__at_orgmortbayjettyhandlerHandlerCollectiondoStartHandlerCollectionjava147__at_orgmortbayjettyhandlerContextHandlerCollectiondoStartContextHandlerCollectionjava161__at_orgmortbaycomponentAbstractLifeCyclestartAbstractLifeCyclejava40__at_orgmortbayjettyhandlerHandlerCollectiondoStartHandlerCollectionjava147__at_orgmortbaycomponentAbstractLifeCyclestartAbstractLifeCyclejava40__at_orgmortbayjettyhandlerHandlerWrapperdoStartHandlerWrapperjava117__at_orgmortbayjettyServerdoStartServerjava210__at_orgmortbaycomponentAbstractLifeCyclestartAbstractLifeCyclejava40__at_orgmortbayxmlXmlConfigurationmainXmlConfigurationjava929__at_sunreflectNativeMethodAccessorImplinvoke0Native_Method__at_sun … >>> More

  • Sunspot / Solr full text search - how to index Rails associations

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Is it possible to index through an association with Sunspot? For example, if a Customer has_many Contacts, I want a 'searchable' block on my Customer model that indexes the Contact#first_name and Contact#last_name columns for use in searches on Customer. acts_as_solr has an :include option for… >>> More

  • Exclude draft articles from Solr index with Sunspot

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I have an indexed model called Article and I don't want solr to index unpublished articles. class Article < ActiveRecord::Base searchable do text :title text :body end end How can I specify that article that is not #published? should not be indexed? >>> More

  • Sunspot_Rails Rake Aborted When Running Reindex

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I'm getting the following output after running rake sunspot:reindex. I'm a novice at Rails. I want to add sunspot_rails to my project to add search functionality (with the hope of deploying the project with Heroku). I'm using Rails 3. I followed the instructions here: https://github.com/outoftime/sunspot/blob/master/sunspot_rails/README… >>> More