sunspot

Use one Solr instance for two Rails apps

試著忘記壹切 提交于 2019-12-13 05:48:59
问题 I have a server set up with several Rails apps, two of which are using Solr Sunspot. However, Solr is returning irrelevant results for a given search, and I believe the problem boils down to not having separated Solr/Sunspot to handle two Rails apps. I have this in one app: class Article < ActiveRecord::Base searchable do text :title, :boost => 2.0 text :body do strip_tags body end time :created_at end end and this in the other: class Article < ActiveRecord::Base searchable do text :title,

Using sunspot to search down model hierarchy

倾然丶 夕夏残阳落幕 提交于 2019-12-13 00:31:56
问题 Example: I have the following: class Person < ActiveRecord::Base has_many :educations end class Education < ActiveRecord::Base belongs_to :school belongs_to :degree belongs_to :major end class School < ActiveRecord::Base has_many :educations # has a :name end I want to be able to return all people who went to a specific school so in my PeopleController#index I have @search = Person.search do keywords params[:query] end @people = @search.results How do I create the searchable method on the

Don't split on underscore with solr.StandardTokenizerFactory

醉酒当歌 提交于 2019-12-12 15:20:27
问题 I'm using solr, I'm using StandardTokenizerFactory in the text field but I don't want to split on the underscore. Do I have to use another toknizer like PatternTokenizerFactory or I can do this with StandardTokenizerFactory ? as I need the same functionality of StandardTokenizerFactory but without split on underscore. 回答1: I don't think you can do it in StandardTokenizerFactory. One solution is to first replace underscores with something the StandardTokenizerFactory won't process and

Performance difference between sunspot and thinking sphinx

落爺英雄遲暮 提交于 2019-12-12 09:19:28
问题 I read an article comparing the performance of sunspot and thinking sphinx ( http://www.vijedi.net/2010/ruby-full-text-search-performance-thinking-sphinx-vs-sunspot-solr/ ). As per the article sunspot drags a lot behind thinking sphinx since it uses xml to interact with java layer. This is the result mentioned there Runs Thinking Sphinx Sunspot 5000 38.49 1611.60 10000 38.54 1648.51 15000 39.06 1614.52 20000 38.86 1583.53 25000 39.78 1613.79 30000 38.83 1595.60 35000 38.34 1571.96 40000 38.06

autocomplete in Solr and sunspot

微笑、不失礼 提交于 2019-12-12 04:33:19
问题 I'm building a website with RoR and I use Sunspot and the solr Search Engine. I needed to use autocomplete functionality but I couldn't. I knew that Solr has a new thing called suggester but I don't know how to use this with sunspot and in a rails app. I found a gem called sunspot_autocomplete and I followed what was written, but when I try to reindex I get this error : rake aborted! RSolr::Error::Http - 400 Bad Request Error: ERROR:unknown field 'tags_ac' The model that is searchable called

Heroku - RSolr::Error::Http (RSolr::Error::Http - 404 Not Found

耗尽温柔 提交于 2019-12-11 20:48:48
问题 In config/sunspot.yml production: solr: hostname: http://index.websolr.com/solr/... port: 8983 log_level: WARNING path: /solr/production ... And my Heroku config variable is http://index.websolr.com/solr/... And everything else seems to be configured as per the docs, but I keep getting 404 messages in the log and app crashes. Has anyone come across this before and managed to fix it? 回答1: To clarify, Sunspot comes bundled with Solr by default, but that is completely separate from your websolr

rails sunspot solr search by keywords

元气小坏坏 提交于 2019-12-11 19:14:02
问题 I am working around search for 2 days to query keyword search using sunspot solr . I am unable to understand My expected output is if i search for laptops in US it should search for laptop and us But the below code search only laptops and not the other words. How can i achieve it. My fulltext is working good I have edited schema.xml <fieldType name="text" class="solr.TextField" omitNorms="false"> <analyzer> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr

How to store timezone info in rails

…衆ロ難τιáo~ 提交于 2019-12-11 17:27:13
问题 In my rails application,users can create questions and publish that, anybody from any country can response for that. We are designing database structure for that. so planning to get user timezone using some js and while answering converting that time and to store in a separate column(tz_created_at). so in created at the date will be stored in utc format, and in another column say tz_created_at the datetime will be stored as user's timezone converted time. (ie) in created_at column i have irb

Sunspot two fulltext queries on two fields

China☆狼群 提交于 2019-12-11 06:28:39
问题 I need to do something like the following, which is meant to issue two different queries on two fields. Video.search do fulltext weighting_factors, {:fields => :categories_as_string} fulltext prefs, {:fields => :similar_as_string} end Currently I force the two fields to include tokens that have separate namespaces and combine the query to apply to both fields. I think this is equivalent since prefs will never match something in categories_as_string but it's a pain to maintain. Is there a way

Sorting the result - sunspot rails

本秂侑毒 提交于 2019-12-11 04:43:45
问题 I have two models, School model and Price model. Every school has a price. Right now I get back the result I want, but I like to implement a sorting function that sorts the highest price for a school and the lowest. School-controller: class SchoolsController < ApplicationController def index @query = params[:search] @search = School.search(:include => [:price] do fulltext params[:search] paginate :page => params[:page], :per_page => 7 end @results = @search.results end end School-model: class