thinking-sphinx

Using crc32 tweak on has_many relations in Thinking Sphinx

萝らか妹 提交于 2019-12-06 12:06:46
It's weird actually. I have two models that have has_many relation each other, here are my models #model city class City < ActiveRecord::Base belong_to :state end #model state class State < ActiveRecord::Base has_many :city end and I have state index ThinkingSphinx::Index.define 'state', :with => :active_record do indexes state_name, :sortable => true #here is the problem has "CRC32(cities.city_name)", :as => :city_name, :type => :integer end I want to use city_name as a filter. My code above doesn't work and i got an error message when run rake ts:index here is the error message ERROR: index

Thinking Sphinx not indexing newly added records

与世无争的帅哥 提交于 2019-12-06 04:54:46
问题 I am using sphinx to search on 2 models along with their associations. I am using delta indexing. Things work fine on my dev box in dev mode (Ubuntu). However, on staging box production env, when I create new records, I need to build the index again in order to make the newly created records searchable. Even weird is that when I create records using script/console, they seem to be getting indexed and are searchable. For the associations to work after update, I have an after_save method for

Loading data from associated model in same query in rails

那年仲夏 提交于 2019-12-06 00:52:23
Basically, I have a Listing model, where each listing has a country id. I need the country name in my search results view. I know I can do @listing.country.name , but this performs an extra query for each listing in my search results. I'm using Thinking Sphinx, and in my controller I have @listings = Listing.search(@ts_params).page(page_num).per(limit) I have tried adding .includes(:countries) and variations thereof but no luck. What's the best way to go about this? I want the country data to be fetched in the same query as the listings. I have exactly the same issue with listing images - it

Sphinx returning bad search results

主宰稳场 提交于 2019-12-05 10:02:00
I am using Sphinx with the Thinking Sphinx plugin. I have indexed a model called Venue with the following code (and the rake thinking_sphinx:index command) define_index do indexes :name indexes city indexes zip end I obtain the results in my controller with this code: @venues = Venue.search params[:search] and I render them as json. The problem I have is that when I hit this URL: http://localhost:3000/venue/list?search=Baltimo I get nothing. But when I hit this URL: http://localhost:3000/venue/list?search=Baltimor I get all Venues located in the city of Baltimore. For some reason that one

Cancan Thinking Sphinx current_ability Questions

倖福魔咒の 提交于 2019-12-05 04:48:29
问题 trying to get cancan working with thinking sphinx but running into some issues. Before using sphinx, I had this in my companies view: @companies = Company.accessible_by(current_ability) That prevented my users from seeing anyone else's companies... After installing sphinx, I ended up with: @companies = Company.accessible_by(current_ability).search(params[:search], :include => :order, :match_mode => :extended ).paginate(:page => params[:page]) Which now displays all my companies and isn't

thinking-sphinx rails2.3.8 ruby 1.8.7

北慕城南 提交于 2019-12-04 23:08:59
支持中文的全文检索 ---test 版 1,去http://www.coreseek.cn/products-install/install_on_bsd_linux/ 下载coreseek,按照官方提供的安装步骤来安装!安装完成 建议测试一下。 2、安装thinking-sphinx gem 包,建议使用淘宝提供的源来安装,比较快。http://ruby.taobao.org/ 3、新建一个项目。然后链接mysql数据库 在你的项目下面的Rakefile文件下面加入 require 'thinking_sphinx/tasks' 4、模型的写法案例:class Pp < ActiveRecord::Base define_index do indexes name, :sortable => true end end 5、然后在config 的目录下面新建一个sphinx.yml 里面的内容为: development: charset_type: zh_cn.utf-8 bin_path: /usr/local/coreseek/bin charset_dictpath: /usr/local/mmseg3/etc ngram_len: 0 6、然后用终端进入你的项目下面:rake ts:conf 7、这样会生成sphinx 需要的配置文件,然后生成索引;rake ts

Any ideas why Thinking Sphinx Rake tasks are not running?

瘦欲@ 提交于 2019-12-04 19:55:33
问题 I'm finding that Thinking Sphinx sometimes errors out when I try to run its Rake tasks. Sometimes the tasks work fine, and sometimes I get errors like the one below. I'm running the tasks as a normal user, not root. Not using sudo. In the example below, searchd is still running after the Rake task fails. I've also seen similar errors with ts:rebuild . Has anyone else seen this? I'm using Sphinx 0.9.9-release (r2117) I'm using Thinking Sphinx 1.4.4 instead of the latest version because I'm on

How do I geo-search multiple models with ThinkingSphinx?

依然范特西╮ 提交于 2019-12-04 18:41:22
I have two models indexed for searching (User and Item). I'm trying to do a geo-search across models: ThinkingSphinx::Search.search('keywords', :geo => [ degrees_to_radians(params[:lat].to_f), degrees_to_radians(params[:lon].to_f) ], ) But I only get an error: Sphinx Error: index item_core,item_delta,user_core,user_delta: unknown latitude attribute '' Searching each model individually works fine... but I've no idea what the problem here is. Here are the indexes: User Index: define_index do indexes [:first_name, :last_name], :as => :name indexes login indexes email indexes headline indexes

Thinking Sphinx not indexing newly added records

一世执手 提交于 2019-12-04 11:27:41
I am using sphinx to search on 2 models along with their associations. I am using delta indexing. Things work fine on my dev box in dev mode (Ubuntu). However, on staging box production env, when I create new records, I need to build the index again in order to make the newly created records searchable. Even weird is that when I create records using script/console, they seem to be getting indexed and are searchable. For the associations to work after update, I have an after_save method for all the association models that set the delta of these two model records to true. I am not sure if this

How to test ThinkingSphinx using RSpec

你离开我真会死。 提交于 2019-12-04 04:24:48
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 in the test db. Please guide me with code examples if you are using rspec with thinking_sphinx