Transcript
Page 1: Apache Solr! Enterprise Search Solutions at your Fingertips!

Apache-Solr! Enterprise Search Solutions at your Fingertips!

Murshed Ahmmad Khan @usamurai, [email protected]

Page 2: Apache Solr! Enterprise Search Solutions at your Fingertips!

Presented at phpXperts seminar 2011…

Page 3: Apache Solr! Enterprise Search Solutions at your Fingertips!

The criteria…

Enterprise Search Server

Page 4: Apache Solr! Enterprise Search Solutions at your Fingertips!

Fast

Page 5: Apache Solr! Enterprise Search Solutions at your Fingertips!

Flexible

Page 6: Apache Solr! Enterprise Search Solutions at your Fingertips!

Powerful

Page 7: Apache Solr! Enterprise Search Solutions at your Fingertips!

Scalable

Page 8: Apache Solr! Enterprise Search Solutions at your Fingertips!

Relevant Results

Page 9: Apache Solr! Enterprise Search Solutions at your Fingertips!

Production ready & Easy deployment

Page 10: Apache Solr! Enterprise Search Solutions at your Fingertips!

What’s in your mind, the name…

??

Page 11: Apache Solr! Enterprise Search Solutions at your Fingertips!

Apache Solr!

Fits all the above mentioned criteria…

Page 12: Apache Solr! Enterprise Search Solutions at your Fingertips!

Solr, What is it…?

q Open Source, Java application q Runs as a standalone full-text search server within any servlet container

q Uses Lucene Java search library as its core

Page 13: Apache Solr! Enterprise Search Solutions at your Fingertips!
Page 14: Apache Solr! Enterprise Search Solutions at your Fingertips!

SOLR WORK FLOW…

Page 15: Apache Solr! Enterprise Search Solutions at your Fingertips!

Solr History… q Developed at CNET Networks by Yonik Seeley

q Donated to ASF (Apache Software Foundation) in early 2006

Page 16: Apache Solr! Enterprise Search Solutions at your Fingertips!

Solr History…(2)

q Incubation period ended in january 2007 (v-1.2 released)

q Solr is now maintained as a subproject of Lucene

Page 17: Apache Solr! Enterprise Search Solutions at your Fingertips!

Solr - Features…

Page 18: Apache Solr! Enterprise Search Solutions at your Fingertips!

Powerful Full-Text search…

Page 19: Apache Solr! Enterprise Search Solutions at your Fingertips!

Hit Highlighting…

Page 20: Apache Solr! Enterprise Search Solutions at your Fingertips!

Faceted Search…

Page 21: Apache Solr! Enterprise Search Solutions at your Fingertips!

Tag Clouds…

Page 22: Apache Solr! Enterprise Search Solutions at your Fingertips!

Geo-spatial search…

Page 23: Apache Solr! Enterprise Search Solutions at your Fingertips!

Solr – Features (cont..) q  Database integration

q  Rich document (Word, PDF) handling

q  REST-like HTTP/XML, JSON APIs (so, you can code virtually in any language)

Page 24: Apache Solr! Enterprise Search Solutions at your Fingertips!

CLIENT API SUPPORT… q  Java (SolrJ), q  .NET (solrnet, SolrSharp), q  PHP (SolPHP), q  Python (SolPython), q  Ruby(on Rails) (rsolr, acts-as-solr,

sunspot), q  C++, q  XML/HTTP, q  JSON/HTTP (AJAX Solr) ++ q  PERL(SolPerl)

Page 25: Apache Solr! Enterprise Search Solutions at your Fingertips!

Solr - Features… (cont…) q  Flexible configuration

q  Extensive Plugin architecture for advanced customization

q  Scalable distributed search, dynamic clustering, index replication

Page 26: Apache Solr! Enterprise Search Solutions at your Fingertips!

Alternatives to Solr q Use Google (GSA – has

integration problems).

q  FAST (Stopped supporting linux)

q  Use Lucene (write code on top of that)

Page 27: Apache Solr! Enterprise Search Solutions at your Fingertips!

Alternatives to Solr…(2) q  Use your Database (has

performance issues)

q  Sphinx (written in C++)

q  Commercial Libraries (e.g. lucidimagination.com)

q  Write your own

Page 28: Apache Solr! Enterprise Search Solutions at your Fingertips!

Who Use Solr/Lucene?

Page 29: Apache Solr! Enterprise Search Solutions at your Fingertips!
Page 30: Apache Solr! Enterprise Search Solutions at your Fingertips!
Page 31: Apache Solr! Enterprise Search Solutions at your Fingertips!

Who use Solr/Lucene…

More names: http://wiki.apache.org/solr/PublicServers

Page 32: Apache Solr! Enterprise Search Solutions at your Fingertips!

OPERATING SYSTEM SUPPORT

q All with a Java VM, including:

q Linux (all versions)

q Windows (all versions)

q MacOS (all versions)

q Unix variants

Page 33: Apache Solr! Enterprise Search Solutions at your Fingertips!

APP SERVER SUPPORT q Apache Tomcat, q Jetty, q Resin, q WebLogicTM, q WebSphereTM, q GlassFish, q dmServerTM, q JBossTM and many more q Java JDK 1.5 or later [requirement]

Page 34: Apache Solr! Enterprise Search Solutions at your Fingertips!

INSTALLATION

1.  Download the latest version of: apache-solr & tomcat

2. Extract it: $tar -xzvf ./apache-solr-1.4.1.tgz $tar -xzvf ./apache-tomcat-6.0.35.tar.gz

Page 35: Apache Solr! Enterprise Search Solutions at your Fingertips!

INSTALLATION

3. copy the solr.war file in the tomcat webapps folder: $ cp apache-solr-1.4.1/dist/apache-solr-1.4.1.war  apache-tomcat-6.0.35/webapps/solr.war

4. copy the example/solr directory into the tomcat home directory $ cp -r apache-solr-1.4.1/example/solr .

Page 36: Apache Solr! Enterprise Search Solutions at your Fingertips!

INSTALLATION

5. start the tomcat server $ ./bin/startup.sh

6. Visit http://localhost:8080/solr/admin/

Page 37: Apache Solr! Enterprise Search Solutions at your Fingertips!

YOU ARE DONE…

Page 38: Apache Solr! Enterprise Search Solutions at your Fingertips!

CREATE SCHEMA.XML <field name="id" type="string" indexed="true" stored="true" required="true" />

<field name="service" type="string" indexed="true" stored="true" required="true" />

<field name="contentType" type="string" indexed="true" stored="true" required="true" />

<field name="dbId" type="long" indexed="true" stored="true" />

<field name="content" type="text" indexed="true" stored="true" />

<copyField source="*" dest=”all” />

Page 39: Apache Solr! Enterprise Search Solutions at your Fingertips!

INDEX DOCUMENTS (INDEXER)

The Common Loop

Page 40: Apache Solr! Enterprise Search Solutions at your Fingertips!

INDEX DOCUMENTS

1.   </add> Add single/multiple documents $doc = new SolrSimpleDocument( array(

new SolrSimpleField('id', ’aawaj-profile-' . $user->id),

new SolrSimpleField('service', 'aawaj'),

new SolrSimpleField('contentType', 'profile'),

new SolrSimpleField('dbId', (string)$user->id)

)); $this->solr->add($doc);

Page 41: Apache Solr! Enterprise Search Solutions at your Fingertips!

INDEX DOCUMENTS

2. </commit>

Commit multiple documents at once.

$this->solr->commit();

Page 42: Apache Solr! Enterprise Search Solutions at your Fingertips!

INDEX DOCUMENTS

3. </optimize>

Optimize, for performance improvement

$this->solr->optimize();

Page 43: Apache Solr! Enterprise Search Solutions at your Fingertips!

SOLR QUERY SYNTAXES

Page 44: Apache Solr! Enterprise Search Solutions at your Fingertips!

QUERY SYNTAXES (RDMS)

SELECT * FROM post WHERE (topic LIKE ‘%apache%’ OR author LIKE ‘%kabir%’)

OR (topic LIKE ‘%solr%’ OR author LIKE ‘%frank%’) ORDER BY id DESC

Page 45: Apache Solr! Enterprise Search Solutions at your Fingertips!

QUERY SYNTAXES (SOLR)

Topic:"The Right Way" AND author:WrongGuy

Page 46: Apache Solr! Enterprise Search Solutions at your Fingertips!

BOOSTING TERMS()

topic: "jakarta apache"^4 "Apache Lucene"

Page 47: Apache Solr! Enterprise Search Solutions at your Fingertips!

FUZZY SEARCH (SOLR)

topic:roam~ (similar in spelling roam)

matches foam roams, based on the Levenshtein Distance, or Edit Distance algorithm

Page 48: Apache Solr! Enterprise Search Solutions at your Fingertips!

PROXIMITY SEARCH (SOLR)

“jakarta apache”~10

search for a "apache" and "jakarta" within 10 words of each other in a document

Page 49: Apache Solr! Enterprise Search Solutions at your Fingertips!

SO, NOW, CAN I MAKE A MINI

GOOGLE?

Page 50: Apache Solr! Enterprise Search Solutions at your Fingertips!

YES, YOU CAN!

q Apache NUTCH, already there

q Open source, Web-search software project.

q Based on Solr...

Page 51: Apache Solr! Enterprise Search Solutions at your Fingertips!

INTERESTED? READ MORE… Ø  http://lucene.apache.org/solr/ Ø  http://wiki.apache.org/solr Ø  http://lucene.apache.org/java/docs/

scoring.html

Ø  http://lucene.apache.org/java/3_5_0/queryparsersyntax.html

Ø  http://www.slideshare.net/erikhatcher/solr-search-at-the-speed-of-light http://www.slideshare.net/pittaya/using-apache-solr

Page 52: Apache Solr! Enterprise Search Solutions at your Fingertips!

WHO AM I… murshed ahmmad Khan head of development,

http://www.usamurai.com @usamurai email: [email protected]

Page 53: Apache Solr! Enterprise Search Solutions at your Fingertips!

THANKS…

Questions?


Top Related