본문 바로가기

IT/Search Engine

Apache Solr



1. server launch (dedicated terminal)
###shell
[jetulis@localhost example]$ sudo java -jar start.jar 
 
2. indexing files : on a different terminal
###shell
[cloudera@localhost exampledocs]$ sudo java -jar post.jar solr.xml monitor.xml  
3. Tada ! search via admin screen
###shell
http://localhost:8983/solr/select/?q=solr&start=0&rows=10&indent=on 
 4. index multiple files : posting 
###shell
[cloudera@localhost exampledocs]$ sudo java -jar post.jar *.xml 
 5. delete by id
###shell
[cloudera@localhost exampledocs]$ java -Ddata=args -jar post.jar "<delete><id>SP2514N</id></delete>"
SimplePostTool: version 1.2
SimplePostTool: POSTing args to http://localhost:8983/solr/update..
SimplePostTool: COMMITting Solr index changes.. 
 6. delete by query
###shell
[cloudera@localhost exampledocs]$ java -Ddata=args -jar post.jar "<delete><query>name:DDR</query></delete>"
SimplePostTool: version 1.2
SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported
SimplePostTool: POSTing args to http://localhost:8983/solr/update..
SimplePostTool: COMMITting Solr index changes.. 
 7. committing : posting will do this automatically
###shell
[cloudera@localhost exampledocs]$ java -jar post.jar 
 8. json return
###shell
http://localhost:8983/solr/select/?q=P120+SP2514N&version=2.2&start=0&rows=10&indent=on&wt=json 
 9. highlighting : w/ <em> tag
&hl=true&hl.fl=name,features&  <-- always hl + hl.fl 
<str>Dual DVI connectors, HDTV out, <em>video</em> input</str> 
10.facet  <-- refine by
###shell
&q=*:*&facet=true&facet.field=cat
&facet=true&facet.field=cat&facet.field=inStock
&q=*:*&fl=name,manufacturedate_dt&facet=true&facet.date=manufacturedate_dt&facet.date.start=2004-01-01T00:00:00Z&facet.date.end=2010-01-01T00:00:00Z&facet.date.gap=%2b2YEAR