Nust 크롤러가 Tire Persistence 모델에 의해 생성 된 ElasticSearch 인덱스로 결과를 직접 전송하는 응용 프로그램이 있습니다.지속성 모델을 사용하여 하나의 인덱스에서 새 인덱스로 가져 오기
인덱스를 삭제할 필요가없는 인덱스를 변경 한 다음 인덱스를 마스터 데이터 원본으로 다시 채우고 다시 채우는 최상의 방법을 찾고 있습니다. 나는 당신의 인덱스가 별칭 인 메소드를 작동시키고, 그 다음에 별칭과 연관된 인덱스를 가지고, 마스터 인덱스에서 새로운 인덱스로 임포트하려고 노력했다.
나는이 접근법으로 작업을 완료하기 위해 rake environment tire:import CLASS='Applicant' INDEX='index_new'
명령을 얻으려고했지만 정의되지 않은 방법 인 '페이지 매김'으로 인해 가져 오기에 실패 했으므로 아무런 성공도 거두지 못했습니다. 내 모델에서 '매김 (paginate)'메쏘드를 사용하면 타이어 - 0.60.0/lib/tire/model/import.rb : 102에서 정의되지 않은 메소드 'count'에서 실패합니다.
나는 올바른 접근법을 찾기 위해 며칠 동안 수색을 해왔고, 지금 시점에서 나는 올바른 길을 가고 있다는 것을 확신하지 못했습니다. 아래 모델을 참조 용으로 포함 시켰습니다. 나는 페이지 매김을 위해 WillPaginate를 사용하고 있습니다. 나도 보조 노트하지만 낮은 우선 순위에
class Applicant
include Tire::Model::Persistence
include Tire::Model::Search
include Tire::Model::Callbacks
require 'will_paginate'
require 'will_paginate-bootstrap'
require 'will_paginate/array'
index_name 'index'
document_type 'doc'
mapping
indexes :boost, type: 'string'
indexes :content, type: 'string'
indexes :digest, type: 'string'
indexes :id, type: 'string'
indexes :skill, type: 'string'
indexes :title, type: 'string'
indexes :tstamp, type: 'date', format: 'dateOptionalTime'
indexes :url, type: 'string'
indexes :domain, type 'string'
property :boost
property :content
property :digest
property :id
property :skill
property :title
property :tstamp
property :url
property :domain
def self.search(params)
tire.search(page: params[:page], per_page: 20)do
query { string params[:query], default_operator: "AND" } if params[:query].present?
filter :term, domain: params[:domain_selected] if params[:domain_selected].present?
filter :term, skill: params[:skill_selected] if params[:skill_selected].present?
facet "domains" do
terms :domain
end
facet "skills" do
terms :skill
end
end
end
def self.paginate(params)
@page_results = WillPaginate::Collection.create(params[:page], per_page, total_entries) do |pager|
pager.replace(@self.to_array)
end
@page_results = @self.paginate(params[:current_page], params[:per_page])
end
end
, 내가 가져 오기 페이지 매김이 필요하고 나에게 분명하지 않다 이유를 이해하려고 노력 코드를 통해 파고 있었어요.
미리 감사드립니다.
첫째, 저에게 다시 연락해 주셔서 감사합니다. 나는 이전에 이것을 시도해 보았고 => "상수"를 첫 번째 것에, 두 번째 줄에 => 참으로 답했다. 나는 단지 재시험을하고 동일한 결과를 받았다. 샘플 데이터베이스에서 가져 오기를 시도 할 때 ActiveRecord를 사용하고 있으면 성공적으로 가져올 수 있습니다. 그러나 현재 아키텍처에서는 결과가 데이터베이스에 저장되지 않고 색인으로 만 저장됩니다. 그래서 Model을 Tire :: Model :: Persistence로 전환하면, 일이 실패하기 시작합니다. 또한 페이지 매김이 필요하며 앱에서 올바르게 작동합니다. 다시 한번 감사드립니다. –