'solr'에 해당되는 글 2건

arirang 분석기

solr 2019. 10. 4. 09:27

arirang.lucene-analyzer-6.2-1.1.0.jar
0.03MB
arirang-morph-1.1.0.jar
0.46MB
stopwords_ko.txt
0.01MB

1. 첨부 jar 파일 server/solr-webapp/webapp/WEB-INF/lib 적

2. lang/stopwords_kor.txt 적용

3. server/solr/board/conf/managed-schema 수정

<filter class="solr.LowerCaseFilterFactory"/>  
<filter class="solr.ClassicFilterFactory"/>  
<filter class="org.apache.lucene.analysis.ko.KoreanFilterFactory" hasOrigin="true" hasCNoun="true" bigrammable="false"/> </filter class="org.apache.lucene.analysis.ko.HanjaMappingFilterFactory"/>  
<filter class="org.apache.lucene.analysis.ko.PunctuationDelimitFilterFactory"/>  
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>  
    
 <analyzer type="query">  
	<tokenizer class="org.apache.lucene.analysis.ko.KoreanTokenizerFactory"/>  
	<filter class="solr.LowerCaseFilterFactory"/>  
	<filter class="solr.ClassicFilterFactory"/>  
	<filter class="org.apache.lucene.analysis.ko.KoreanFilterFactory" hasOrigin="true" hasCNoun="true" bigrammable="false"/> </filter class="org.apache.lucene.analysis.ko.WordSegmentFilterFactory" hasOrijin="true"/>  
	<filter class="org.apache.lucene.analysis.ko.HanjaMappingFilterFactory"/>  
	<filter class="org.apache.lucene.analysis.ko.PunctuationDelimitFilterFactory"/>  
	<filter class="solr.StopFilterFactory" words="lang/stopwords_tr.txt" ignoreCase="true"/>
</analyzer>


  

'solr' 카테고리의 다른 글

solr  (0) 2019.10.04
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,

solr

solr 2019. 10. 4. 09:22

1. solr 시작

Windows: bin\solr start 
Mac, Linux: bin/solr start

2. 브라우저 실행

http://localhost:8983/solr

3. Core Collection 생성

Windows: bin\solr create -c record -d ..\server\solr\configsets\basic_configs 
Mac, Linux: bin/solr create -c record -d ../server/solr/configsets/basic_configs

* v7.7.2 변경

solr create -c record -d ..\server\solr\configsets\_default

4. 생성 콜렉션 확인

http://localhost:8983/solr

5. $SOLR_HOME\server\solr\board\conf > managed-schema 수정

<field name="title" type="text_general" indexed="true" stored="true" multivalued="false" /> 
<field name="writer" type="string" indexed="true" stored="true" multivalued="false" /> 
<field name="board" type="text_general" indexed="true" stored="true" multivalued="false" /> 
<field name="date" type="date" indexed="true" stored="true" multivalued="false" /> 
  
<field name="text" type="text_general" indexed="true" stored="true" multivalued="true" /> 
<copyfield source="title" dest="text" /> 
<copyfield source="writer" dest="text" /> 
<copyfield source="board" dest="text" />

6. solr restart

Windows: bin\solr restart -p 8983 
Mac, Linux: bin/solr restart 

7. pom.xml

https://mvnrepository.com/artifact/org.apache.solr/solr-solrj

8. SolrJDriver.class 생성

public class SolrJDriver { 
    public static String url = "https://localhost:8983/solr/record"; 
    public static SolrClient solr = new HttpSolrClient(url);  
}

9. solr에 document 추가/삭제/조회
* 추가

SolrInputDocument solrDoc = new SolrInputDocument(); 
solrDoc.addField("id", param.getBrdno()); 
solrDoc.addField("title", param.getBrdtitle()); 
solrDoc.addField("writer", param.getBrdwriter()); 
solrDoc.addField("board", param.getBrdmemo()); 
solrDoc.addField("date", param.getBrddate()); 
  
Collection solrDocs = new ArrayList(); 
solrDocs.add(solrDoc); 
  
SolrJDriver.solr.add(solrDocs); 
SolrJDriver.solr.commit();

* 삭제

SolrJDriver.solr.deleteById(param);
SolrJDriver.solr.commit() 

* 전체삭제

deleteByQuery(QUERY_STATEMENT)  

* 조회

if(!"".equals(q)) { 
  SolrQuery query = new SolrQuery(); 
  query.setQuery("text:" + q ); 
  
  QueryResponse responseSolr = SolrJDriver.solr.query(".", query); 
  SolrDocumentList results = responseSolr.getResults(); 
  
  modelMap.addAttribute("q", q); 
  modelMap.addAttribute("listview", results.toArray()); 
}

'solr' 카테고리의 다른 글

arirang 분석기  (0) 2019.10.04
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,