introduction to lucene and solr - 2

13
Day 2 – Solr Hands On Core Tech @Trend Micro 吳吳吳 YI-CHING WU 1

Upload: yi-ching-wu

Post on 20-Aug-2015

327 views

Category:

Software


4 download

TRANSCRIPT

Page 1: Introduction to Lucene and Solr - 2

1

Day 2 –Solr Hands OnCore Tech @Trend Micro

吳奕慶 YI-CHING WU

Page 2: Introduction to Lucene and Solr - 2

2 Preparation

NB/PC or VM

Install JRE

Install Tomcat on Windows / Linux

Download Solr 4.6

Download JDBC : sqljdbc4.jar

Un-Zip Solr 4.6

Page 3: Introduction to Lucene and Solr - 2

3 Install Solr on Windows install java runtime

download Tomcat windows service and install it to d:\Tomcat

test Tomcat site http://localhost:8080

stop Tomcat

download Solr and Unzip to d:\tempsolr

copy d:\tempsolr\dist\solr-x.x.x.war to d:\tomcat 

rename d:\tomcat\solr-x.x.x.war to  d:\tomcat\solr.war

copy d:\tempsolr\example\solr\ to d:\websolr\

add Java Options -Dsolr.solr.home=d:\websolr 

add Java Options -Dsolr.velocity.enabled=false

copy d:\tempsolr\example\lib\ext to d:\tomcat\webapps\solr\WEB-INF\lib\

created:\tomcat\webapps\solr\WEB-INF\classes\ 

copy d:\tempsolr\example\resource\log4j.properties to d:\tomcat\webapps\solr\WEB-INF\classes\

start Tomcat

visit http://localhost:8080/solr/

Page 4: Introduction to Lucene and Solr - 2

4 Setup Schema.xml

Data source overview

Edit the schema.xml

Page 5: Introduction to Lucene and Solr - 2

5 Import Data to Solr- Data import Handler

Conntect to “TW-TSDev01”

Add new “/dataimport” request handler

Edit “data.import.xml"

Command

http://localhost:8080/solr/core0/dataimport?command=full-import&commit=ture

http://localhost:8080/solr/core0/dataimport?command=delta-import&clean=false&commit=ture (dataimport.properties)

http://wiki.apache.org/solr/DataImportHandler

Page 6: Introduction to Lucene and Solr - 2

6 Commands example

Page 7: Introduction to Lucene and Solr - 2

7 Scheduling and dataimport.properties.xml

/lib/apache-solr-dataimportscheduler.jar 

Tomcat : /solr.war

<listener><listener-class> org.apache.solr.handler.dataimport.scheduler.ApplicationListener</listener-class></listener>

Page 8: Introduction to Lucene and Solr - 2

8 Query data - Solr administration Console

Analysis

DataImport

Try to query the data we feed to Solr

Page 10: Introduction to Lucene and Solr - 2

10 Full exampleq=osce&start=0&rows=10&wt=xml&indent=false

&defType=edismax

&hl=true&hl.fl=Title%2CSegment%2CProblems%2CPublicContent

&hl.simple.pre=%3Cem%3E&hl.simple.post=%3C%2Fem%3E&hl.usePhraseHighlighter=true&hl.highlightMultiTerm=true

&facet=true&facet.query=osce

&facet.field=Segment,OperatingSystem

&spellcheck=true&spellcheck.build=true&spellcheck.reload=true

&spellcheck.q=oscc

&spellcheck.onlyMorePopular=true

&spellcheck.accuracy=0.7

Page 11: Introduction to Lucene and Solr - 2

11 Setup solrconfig.xml

Spell checking

Suggestion

List Terms of field

MLT – more like this

Page 12: Introduction to Lucene and Solr - 2

12 SolrJ

Library to connect and interact with Solr

Page 13: Introduction to Lucene and Solr - 2

13 Thank You!