Sunspot 세팅
먼저 gem 설치 경로로 가서 sunspot_solr-1.3.0 디렉토리를 찾는다. (1.3.0 버전 기준)
(rvm + ruby-1.9.2.-p180 환경에서는 /Users/sunho/gems1.9.2-p180/gems/sunspot_solr-1.3.0/ 이다)
여기에 lib/sunspot/solr/server.rb 를 편집하자. 여기에 서버 구동코드가 들어 있다.
def run
bootstrap
command = ['java']
command << "-Xms#{min_memory}" if min_memory
command << "-Xmx#{max_memory}" if max_memory
command << "-Djetty.port=#{port}" if port
command << "-Djetty.host=#{bind_address}" if bind_address
command << "-Dsolr.data.dir=#{solr_data_dir}" if solr_data_dir
command << "-Dsolr.solr.home=#{solr_home}" if solr_home
command << "-Djava.util.logging.config.file=#{logging_config_path}" if logging_config_path
command << '-jar' << File.basename(solr_jar)
FileUtils.cd(File.dirname(solr_jar)) do
exec(Escape.shell_command(command))
end
end
저 command 들을 수정해야 한다.
참고로 multicore가 적용된 solr 실행스크립트는 다음과 같다.
java -Dsolr.solr.home=multicore -Dsolr.abortOnConfigurationError=true -Dfile.encoding=UTF-8 -Duser.language=ko -Duser.country=KR -jar start.jar
여기서 -Dfile, -Duser.language, -Duser.country 변수들을 위의 루비 코드에 추가하자.
def run
bootstrap
command = ['java']
command << "-Xms#{min_memory}" if min_memory
command << "-Xmx#{max_memory}" if max_memory
command << "-Djetty.port=#{port}" if port
command << "-Djetty.host=#{bind_address}" if bind_address
command << "-Dsolr.data.dir=#{solr_data_dir}" if solr_data_dir
command << "-Dsolr.solr.home=#{solr_home}" if solr_home
command << "-Djava.util.logging.config.file=#{logging_config_path}" if logging_config_path
command << "-Dfile.encoding=#{file_encoding}" if file_encoding
command << "-Duser.language=#{user_language}" if user_language
command << "-Duser.country=#{user_country}" if user_country
command << '-jar' << File.basename(solr_jar)
FileUtils.cd(File.dirname(solr_jar)) do
exec(Escape.shell_command(command))
end
end
attr_accessor에도 잊지말고 추가하자.
attr_accessor :min_memory, :max_memory, :bind_address, :port, :solr_data_dir, :solr_home, :log_file, :file_encoding, :user_language, :user_country
이 파일은 application_root/config/ 에 있다.
development: solr: hostname: localhost port: 8982 log_level: INFO file_encoding: UTF-8 user_language: ko user_country: KR
이제 서버를 띄워 확인해 보자.
rake sunspot:solr:start
한글 형태소 분석기는 네이버까페에서 받아 설치한다. (이건 생략)
설치한 형태소 분석기가 포함되어 있는 웹 프로젝트를 war로 묶는다.
jar cvf solr.war .
sunspot_solr1.3.0/solr/webapp/solr.war 파일을 적당한곳에 백업해놓고 새로 묶은 war파일로 대체한다.