2017-05-22 57 views
0

因此,我承担了一个较大的项目,并且不确定在哪里查找修改此代码的代码。我们有一个数据库,在这里它被看作Essay - > Section - > figure,我们试图添加一个名为'video_url'的新列。我相信这与非规范化有关,但我不完全确定。修改弹性搜索查询的结果列

这里的作文模式:

class Essay 
    include ActiveModel::Model 
    include ActiveModel::Serialization 
    include Draper::Decoratable 
    include Import::HtmlEssay 
    include Searchable 

    FACETS = %w(author) 
    FULLTEXT_FIELDS = %w(title sections.title sections.body sections.figures.caption) 

    def self.define_mappings! 
    mapping mapping_options do 
     analyzer = I18n.locale == :tr ? :turkish : :snowball 

     indexes :author, index: :not_analyzed 
     indexes :publication_id, index: :not_analyzed 
     indexes :sequence, type: 'long' 
     indexes :title, analyzer: analyzer 
     indexes :sections do 
     indexes :title, analyzer: analyzer 
     indexes :body, analyzer: analyzer 
     indexes :figures do 
      indexes :caption, analyzer: analyzer 
     end 
     end 
    end 
    end 

    class Query 
    include Searchable::Query 

    def sort 
     [ 
     { publication_id: { order: 'asc'}}, 
     { sequence: { order: 'asc' }} 
     ] 
    end 
    end 
end 

现在它只是显示[醪标题,信贷,数字(#),URL]。我想将video_url附加到Image模型的一部分(这是我们从中拉出URL的地方),但我不确定这是如何工作的,并且遇到了麻烦。我认为他们使用的唯一相关的gem是elasticsearch-model,但是我经历了一堆他们的东西,我仍然不确定。

的控制,以及(虽然没有真的发生在这里)如下:

class EssaysController < SearchBaseController 
    def show 
    @essay = Essay.find(params[:id]).decorate 
    end 
end 

老实说,即使你不知道答案,如果你能告诉我在哪里,甚至像“FULLTEXT_FIELDS” VAR事情来自这将是非常有益的,我可以编辑这个来添加其他代码段,如果需要的话。我真的需要弄清楚如何将video_url列添加到结果中,它在elasticsearch中,并且可以用其他方法访问,但是这里没有显示。

回答

0

所以我最终发现/ models/concerns/import/*里面还有另一个文件夹,里面包含了关于数据库设置的更多信息。我不确定他们使用的是什么宝石/为什么这样设置,但我会在更多地了解它时更新这个答案。