У меня есть следующая модель:мышление Sphinx без условия
class Article < ActiveRecord::Base
define_index do
indexes content
indexes :name, sortable: true
has type
end
end
и особый тип статьи является:
class About < Article
end
и то же самое для Contact
Я хотел бы иметь для поиска статьи с индексом без статей с типом «О» или «Контакт»
class ArticlesController < ApplicationController
load_and_authorize_resource
def index
@articles = Article.search(params[:search],
:with_all => {:type => nil},
:page => params[:page],
:per_page => 10)
end
end
Но переменная экземпляра @articles
содержит каждое время также «О» & «Контакт».
Это очень странно (похоже will_paginate Мессинг все вверх):
@articles = Article.search(
:without => {:type => %w(About Contact)}).include?(About.first) # false
@articles = Article.search(
:without => {:type => %w(About Contact)},
:page => 1,
:per_page => 1000).include?(About.first) # true
========================== ================================================== =
Наконец я сделал:
class Article < ActiveRecord::Base
define_index do
indexes content
indexes :name, sortable: true
has "CRC32(type)", :as => :article_type, :type => :integer
end
end
и:
class ArticlesController < ApplicationController
load_and_authorize_resource
def index
@articles = Article.search(params[:search],
:without => {:article_type => ["About".to_crc32, "Contact".to_crc32]},
:page => params[:page],
:per_page => 10)
end
end
и он работает. Спасибо, парни!
В этом случае я получаю: ошибку Searchd (статус: 1): недействительный или усеченный запрос – Ch4rAss