English 中文(简体)
铁路+Sunspot:多模型搜索,但只有某一模型的某些领域?
原标题:Rails + Sunspot: Multiple model search, but only certain fields on one of the models?

在我的铁路中,使用Sunspot为几个不同的模型设计了Im。 然后,我有一个全球搜索表,结果好坏参半。 罚款:

Sunspot.search(Person, EmailAddress, PhoneNumber, PhysicalAddress) do
  fulltext params[:q]
  paginate :per_page => 10
end

我要在这次搜索中增加一个模式,即项目。 项目模式有相当的参数,其指数是:

class Project < ActiveRecord::Base
  searchable do
    string :category do
      category.name.downcase if category = self.category
    end

    string :client do
      client.name.downcase if client = self.client
    end

    string :status

    text :tracking_number
    text :description

    integer :category_id, :references => Category
    integer :client_id, :references => Client
    integer :tag_ids, :multiple => true, :references => Tag

    time :created_at, :trie => true
    time :updated_at, :trie => true
    time :received_at, :trie => true
    time :completed_at, :trie => true
  end
end

我如何能够修改我的原始<代码>Sunspot.search。 仅通过<条码>查询<>外地和not<>>>查询项目记录 www.un.org/Depts/DGACM/index_french.htm

问题回答
Sunspot.search(Person, EmailAddress, PhoneNumber, PhysicalAddress, Project) do
  fulltext params[:q] do
    fields(:tracking_number, :other_fields_outside_your_project_model)
  end

  paginate :per_page => 10
end

这将对跟踪——数字领域和你具体指明的任何其他领域进行全文搜索,特别是在你个人、电子邮件、电话和物理压力模型中。

我认为,你必须把跟踪定义为文字领域,而不是扼杀领域。 只读“文字领域”。

您:

text:tracking_number

你们的太阳探测器也像:

Sunspot.search(Person, EmailAddress, PhoneNumber, PhysicalAddress, Project) do
  fulltext params[:q]
  paginate :per_page => 10
end

你们尝试的是:

Sunspot.search(Post) do
  keywords  great pizza , :fields => [:title, :body]
end

你可以要求每个模式,然后把结果编成一个清单。 我认为,你可以做一次搜查。





相关问题
Acronyms with Sphinx search engine

how can i index acronyms like m.i.a. ? when i search for mia , i get results for mia and not m.i.a. . when i search for m.i.a. , i get nothing at all. edit: solution looks roughly like: ...

Querying multiple index in django-sphinx

The django-sphinx documentation shows that django-sphinx layer also supports some basic querying over multiple indexes. http://github.com/dcramer/django-sphinx/blob/master/README.rst from ...

Adding Search to Ruby on Rails - Easy Question

I am trying to figure out how to add search to my rails application. I am brand new so go slow. I have created a blog and done quite a bit of customizing including adding some AJAX, pretty proud of ...

Searching and ranking short phrases (e.g. movie titles)

I m trying to improve our search capabilities for short phrases (in our case movie titles) and am currently looking at SQL Server 2008 Full Text Search, which provides some of the functionality we ...

Will Full text search consider indexes?

Ok I have a full text search index created on my JobsToDo table, but what I m concerned about is if this is rendering my other indexes on the table useless. I have a normal nonclustered index on the ...

Lucene.NET on shared hosting

I m trying to get Lucene.NET to work on a shared hosting environment. Mascix over on codeproject outlines here how he got this to work on godaddy. I m attempting this on isqsolutions. Both ...

Hibernate Search or Compass

I can t seem to find any recent talk on the choice. Back in 06 there was criticism on Hibernate Search as being incomplete and not being ready to compete with Compass, is it now? Has anyone used both ...

热门标签