sunspot

How Do I Scope Enums in Rails Using Sunspot?

北城余情 提交于 2019-12-22 18:19:49
问题 I am trying to use Sunspot (Rails Solr gem) to scope results using an enum I have declared in my model. The relevant portion of my model looks like this: searchable do text :tag_list boolean :approved integer :perspective time :created_at end enum perspective: [ :not_applicable, :front, :side_front, :side, :side_back, :back, :above, :below ] My search block in my controller looks like this: def index //skip scoping if perspective is nil params[:perspective] ||= [] @search = Upload.search do

Can sunspot search inside array?

不羁岁月 提交于 2019-12-21 05:04:32
问题 I have the next model with a array field: Class Invitation include Mongoid::Document include Mongoid::Timestamps::Created include Sunspot::Mongo field :recipients, :type => Array attr_accessible :recipients searchable do text :recipients do recipients.map { |recipient| recipient } end end end I have in my controller: def recipients @invitation = Invitation.find(params[:id]) @search = Invitation.search do |s| s.fulltext params[:search] s.with(:recipients, @invitation.recipients) end

How do I dynamically build a search block in sunspot?

孤者浪人 提交于 2019-12-21 04:55:27
问题 I am converting a Rails app from using acts_as_solr to sunspot. The app uses the field search capability in solr that was exposed in acts_as_solr. You could give it a query string like this: title:"The thing to search" and it would search for that string in the title field. In converting to sunspot I am parsing out field specific portions of the query string and I need to dynamically generate the search block. Something like this: Sunspot.search(table_clazz) do keywords(first_string, :fields

Date range facets with Sunspot in Ruby on Rails

本小妞迷上赌 提交于 2019-12-21 02:41:37
问题 I am using Sunspot to search for events (parties, concerts, ...) in a Ruby on Rails 3 application. I have managed to set up free text search and facet search on a couple of different category types. Now, I am stuck with my next task. I want to set up facets related to when the event is occuring. I want to have facets describing both relative date/time ranges such as "today", "this weekend", "next weekend" and absolute date/time ranges , such as "Easter Holiday 2011", "New Years Day 2012", ...

Date range facets with Sunspot in Ruby on Rails

我只是一个虾纸丫 提交于 2019-12-21 02:41:05
问题 I am using Sunspot to search for events (parties, concerts, ...) in a Ruby on Rails 3 application. I have managed to set up free text search and facet search on a couple of different category types. Now, I am stuck with my next task. I want to set up facets related to when the event is occuring. I want to have facets describing both relative date/time ranges such as "today", "this weekend", "next weekend" and absolute date/time ranges , such as "Easter Holiday 2011", "New Years Day 2012", ...

How to rotate, override, or turn off logging from Sunspot Solr Rubygem?

折月煮酒 提交于 2019-12-20 14:32:33
问题 I've had great experiences with Sunspot Solr search for Ruby on Rails, however, its log files are growing incredibly large and I can't seem to find a way to either rotate , override , or turn off these logs (other than with very hacky methods that I'd rather not pursue). I have a file, sunspot.yml in config/ , where I tried setting the log_level flags to SEVERE , however, this had no effect. I tried using the standard Logger.config rotation methods, however, that just sent my development log

Sunspot with multiple models (in Rails)

こ雲淡風輕ζ 提交于 2019-12-20 08:49:55
问题 I have three models ( User , Tag , Product ) and they interact s.t. User has many Tags and Products . For searching purposes, I would like to be able to search (with one search bar) on user names, tag names, and product descriptions. I would also like to search on product pages, but that is only relevant for tag names and product descriptions. Here are two examples: Search: "Linus Torvalds" returns all instances of Linus Torvalds in the three models with any instances of the user name being

Exclude draft articles from Solr index with Sunspot

雨燕双飞 提交于 2019-12-19 08:53:04
问题 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? 回答1: Be sure to index the published status. class Article < ActiveRecord::Base searchable do text :title text :body boolean :is_published, :using => :published? end end Then add a filter to your query Sunspot.search(Article) do |search| search

Rails app: Solr throwing RSolr::Error::Http - 404 Not Found when executing search

戏子无情 提交于 2019-12-17 22:18:55
问题 Very lost as I haven't made any changes to my search which has always been working but somehow I've got a break. Being relatively new to Rails, the error output isn't giving me enough detail to debug. Relevant code below - ask if you want to see anything else. home.html.slim (excerpt with search form) = form_tag search_venues_path, method: :get, id: 'search' do |f| .search-fields.span16 p = text_field_tag :q, '', placeholder: "Search for coffee, hotel, etc", class: 'span7 search-field' p =

how to implement wildcard search with sunspot

老子叫甜甜 提交于 2019-12-14 01:55:19
问题 any help is always welcome I am using sunspot with solr but not able to find any good solution that how to perform wildcard search with sunspot if i search for 8088* * * it should return all numbers starts with 8088 but not 228088560 回答1: Look for the following lines of code in /solr/conf/schema.xml: <fieldType name="text" class="solr.TextField" omitNorms="false"> ... </fieldType> and replace them with this: <fieldType name="text" class="solr.TextField" omitNorms="false"> <analyzer type=