Download - เกี่ยวกับ Apache solr 4.0
Apache Solr@somkiat
Apache Solr
Search server
Based on Lucene
Full-text search library
Java 100%
Open source
Apache SolrREST API
HTTP
XML
JSON
Apache SolrClient supports
.NET
Java
PHP
Ruby
Python
How we implement ?
SELECT * FROM product
WHERE id LIKE ‘%1%’ AND name LIKE ‘%xxx%’
Problems
Full table scan = Killer performance
RDBMS is not designed for search like that
Architecture
Indexer
Apache Solr
WEB Application
Query
ResultUpdate
How to use ?Install
Define solrconfig.xml
Define schema.xml
Deploy to Java Web Server
Jetty ( Default )
Apache Tomcat
Define schema.xml
Structure of data
Liked table structure
Must have Primary/Unique key
Must have _version_ field
<field name="id" type="string" indexed="true" stored="true" required="true" /> !
<field name="item_id" type="string" indexed="true" stored="true" required="true" /> <uniqueKey>id</uniqueKey>
Dashboard page
Add/Update index
Add/Update Index
http://localhost:8983/solr/collection1/update?wt=json
Delete Index
http://localhost:8983/solr/collection1/update?stream.body=<delete><query>*:*</query></delete>&commit=true
Ping
http://localhost:8983/solr/collection1/admin/ping?wt=json
Scaling SolrScale up
CPU, RAM, SSD
Scale horizontal
(http://wiki.apache.org/solr/DistributedSearch)
Scale deep
Sharding and Multiple replicate
Performance ToolsJMeter
SolrMeter
https://code.google.com/p/solrmeter/
http://wiki.apache.org/solr/BenchmarkingSolr
JMeter
SolrMeter
Tuning performance
http://wiki.apache.org/solr/SolrPerformanceFactors
JVM Memory
-Xms1024M -Xmx1024M -server
Virtual Memory
Virtual memory for index
Config in solrconfig.xml
<directoryFactory/>
change from StandardDirectoryFactory to MmapDirectoryFactory
Enable http caching
Config in solrconfig.xml
<httpCaching lastModifiedFrom="openTime" etagSeed="Solr" never304="false"> <cacheControl> max-age=43200, must-revalidate </cacheControl> !
</httpCaching>
Q/A