thinking-sphinx

How to test ThinkingSphinx using RSpec

随声附和 提交于 2019-12-21 09:29:27
问题 I have a class method in a model that calls thinking_sphinx's search() method. I need to check this class method. I want to start, index or stop sphinx in my rspec test cases. I am trying with this piece of code. before(:all) do ThinkingSphinx::Test.start end after(:all) do ThinkingSphinx::Test.stop end and with this code in each test case before I fire the search query ThinkingSphinx::Test.index but still after I fire the search query, it gives me empty results though exact matches are there

How do I add the condition “IS NOT NULL” to a Thinking Sphinx search

谁都会走 提交于 2019-12-21 04:22:14
问题 I'm using Thinking Sphinx for full-text search, following this video. I'd like to do the following: @articles = Article.search(params[:search], :conditions => "published_at IS NOT NULL", :order => :created_at) The problem is that this doesn't work. It seems that the search method only accepts conditions that are a hash. I've tried a couple of ways, but I am clueless as to how I can represent "published_at IS NOT NULL" as a hash... 回答1: Was given the solution over at Railscasts If you want

How do I add the condition “IS NOT NULL” to a Thinking Sphinx search

不羁岁月 提交于 2019-12-21 04:22:03
问题 I'm using Thinking Sphinx for full-text search, following this video. I'd like to do the following: @articles = Article.search(params[:search], :conditions => "published_at IS NOT NULL", :order => :created_at) The problem is that this doesn't work. It seems that the search method only accepts conditions that are a hash. I've tried a couple of ways, but I am clueless as to how I can represent "published_at IS NOT NULL" as a hash... 回答1: Was given the solution over at Railscasts If you want

thinking sphinx and console

佐手、 提交于 2019-12-20 05:37:06
问题 I am having a problem with Thinking sphinx on webfaction -- I have no probelem when I do it locally on osx. I search >> ThinkingSphinx.search 'raymond' and my response is this: => [] any ideas? thx sg 回答1: If you have not already, you should run rake ts:index If you would like your search to update every time you make a change, I would suggest looking into Delta Indexes also. 回答2: Are you using AwesomePrint by any chance? I am and that is what was causing my problem. You can see the bug

Relation won't index

旧城冷巷雨未停 提交于 2019-12-13 06:58:33
问题 I'm having some problem indexing one of my models. Here is my model: class Model < ActiveRecord::Base define_index do # ... has tracker.open, as: :open, type: :boolean has source.priority, as: :priority, type: :integer # ... end belongs_to :tracker belongs_to :source end I'm running this to index the model: rake thinking_sphinx:index --trace Here is the error: undefined method `priority' for #<ThinkingSphinx::Source:0x00000106ae1738> Anyone knows why the tracker relations works, but not the

Search by year with Thinking Sphinx

拟墨画扇 提交于 2019-12-13 05:16:54
问题 I have Category model with many Topics. Each Topic has many Posts. Posts have fields 'rating' (float), and 'created_at' (DateTime). I am using Thinking Sphinx for searching different fields in Category and I'm trying to add little more complicated search option. I would like to find Categories with rating for example below 4.5 for Posts from this year only. Other example would be finding Categories with rating above 6.7 for Posts from year 2009 etc. So far I created indexing like this:

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

Intersect thinking sphinx results

泪湿孤枕 提交于 2019-12-12 05:06:16
问题 Is it possible to intersect two ThinkingSphinx results? For example, I have the results of two queries with the same object types: result_1 = [A1, A2] and result_2 = [A2, A3] . How can I get the intersection result_1 & result_2 (which should be [A2]), as I can with regular ruby arrays? I'm using Thinking Sphinx version 3.0.6. Thanks. 回答1: If you want to combine the raw arrays from two searches, you can do this using the to_a method: result_1.to_a & result_2.to_a The catch here, though, is you

Thinking-spinx breaks belongs_to built-in validation

吃可爱长大的小学妹 提交于 2019-12-12 03:49:37
问题 Ubuntu 16.04.1 LTS Rails 5.0.0 ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu] gem 'mysql2', '~> 0.3.18', :platform => :ruby gem 'thinking-sphinx', '~> 3.2.0' PostgreSQL 9.5.3 I set up the Sphinx search engine in my Rails 5 project and it broke the Rails belongs_to built-in validation. Example: class Post < ApplicationRecord belongs_to :user end class Article < ApplicationRecord belongs_to :user end class User < ApplicationRecord has_many :posts has_many :articles end Earlier when I created a

Thinking sphinx search returns nothing when multiple index files used on a single model

谁说胖子不能爱 提交于 2019-12-12 02:24:57
问题 Searching sometimes yields no results when my sphinx indices are separated into multiple files in one model. The versions I'm using: Rails - 4.1 Thinking Sphinx - 3.0.6 Sphinx - 2.0.9 I have five indices on this model: ThinkingSphinx::Index.define :incident, name: "incident_index_1" ... do indexes name end ThinkingSphinx::Index.define :incident, name: "incident_index_5" ... do indexes tags.name, as: :tag indexes custom_fields_values.value, as: :custom end Searching separately, the queries