SlideShare ist ein Scribd-Unternehmen logo
1 von 66
Downloaden Sie, um offline zu lesen
Make Plone Search Act
Like Google Using Solr
  Clayton Parker | Senior Web Developer
          PLONE CONFERENCE 2011
Who Am I
What will we learn?   PLONE CONFERENCE 2011
What will we learn?   PLONE CONFERENCE 2011




• Intro to Solr
What will we learn?                        PLONE CONFERENCE 2011




• Intro to Solr
• Brief overview of Plone integration points
What will we learn?                        PLONE CONFERENCE 2011




• Intro to Solr
• Brief overview of Plone integration points
• Solr configuration
What will we learn?                        PLONE CONFERENCE 2011




• Intro to Solr
• Brief overview of Plone integration points
• Solr configuration
• Solr schema setup
What will we learn?                        PLONE CONFERENCE 2011




• Intro to Solr
• Brief overview of Plone integration points
• Solr configuration
• Solr schema setup
• Debugging tips and tricks
PLONE CONFERENCE 2011




What is Solr            ?
Version Madness                             PLONE CONFERENCE 2011




   1.x
 (up to 1.4)




                 1.5
           (number abandoned)



                                   3.x
                         (merge of Lucene and Solr)
Books   PLONE CONFERENCE 2011
PLONE CONFERENCE 2011




Integration
PLONE CONFERENCE 2011




alm.solrindex
PLONE CONFERENCE 2011




collective.solr
Solr Configuration
Query Handlers                     PLONE CONFERENCE 2011




• Standard
• Disjunction Max (DisMax)
• Extended DisMax (experimental)
DisMax                      PLONE CONFERENCE 2011




• Multiple index searches
• Boosting
• Friendlier to end users
DisMax                                      PLONE CONFERENCE 2011




   Index Name

      qf=SearchableText^1.0 substring^0.2




                           Weight
MinShouldMatch                           PLONE CONFERENCE 2011




   mm=100%


                All terms required
   mm=50%


            Half of the terms required
   mm=-2


            All but two terms required
MinShouldMatch                        PLONE CONFERENCE 2011




               mm=2<-25% 9<-3




   2 or less   3-9 terms all    more than 9
  terms are      but 25%        terms all but
   required      required         three are
                                  required
Spelling Component                                     PLONE CONFERENCE 2011




<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
  <lst name="spellchecker">
    <str name="name">default</str>
    <str name="classname">solr.IndexBasedSpellChecker</str>
    <str name="buildOnCommit">true</str>
    <str name="spellcheckIndexDir">path/to/spellcheck</str>
    <!-- The field that will contain the dynamic spelling data -->
    <str name="field">spell</str>
    <str name="accuracy">0.5</str>
  </lst>
  <!-- Control indexing and query of spelling data -->
  <str name="queryAnalyzerFieldType">spell-text</str>
</searchComponent>
Spelling Schema                                        PLONE CONFERENCE 2011




<fieldType name="spell-text" class="solr.TextField">
  <analyzer>
    <tokenizer class="solr.ICUTokenizerFactory"/>
    <filter class="solr.ICUFoldingFilterFactory"/>
    <filter class="solr.StopFilterFactory"
        ignoreCase="true" words="stopwords.txt"/>
  </analyzer>
</fieldType>
Solr Schema
Index vs Query                                                         PLONE CONFERENCE 2011




      http://www.cominvent.com/2011/04/04/solr-architecture-diagram/
PLONE CONFERENCE 2011
PLONE CONFERENCE 2011




Character Filters
PLONE CONFERENCE 2011




Character Filters




   Tokenizer
PLONE CONFERENCE 2011




Character Filters




   Tokenizer




     Filters
PLONE CONFERENCE 2011




Character Filters




   Tokenizer




     Filters
Complete Field                                                        PLONE CONFERENCE 2011

 <fieldType name="text" class="solr.TextField" positionIncrementGap="100">
   <analyzer type="index">
     <charFilter class="solr.MappingCharFilterFactory" mapping="mapping.txt"/>
     <tokenizer class="solr.ICUTokenizerFactory"/>
     <filter class="solr.ICUFoldingFilterFactory"/>
     <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
         ignoreCase="true" expand="true"/>
     <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
     <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>
     <filter class="solr.WordDelimiterFilterFactory" splitOnCaseChange="1"
         splitOnNumerics="1" stemEnglishPossessive="1" generateWordParts="1"
         generateNumberParts="1" catenateWords="0" catenateNumbers="0"
         catenateAll="0" preserveOriginal="1"/>
   </analyzer>

   <analyzer type="query">
     <charFilter class="solr.MappingCharFilterFactory" mapping="mapping.txt"/>
     <tokenizer class="solr.ICUTokenizerFactory"/>
     <filter class="solr.ICUFoldingFilterFactory"/>
     <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
     <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/>
     <filter class="solr.WordDelimiterFilterFactory" splitOnCaseChange="1"
         splitOnNumerics="1" stemEnglishPossessive="1" generateWordParts="1"
         generateNumberParts="1" catenateWords="0" catenateNumbers="0"
         catenateAll="0" preserveOriginal="1"/>
     <filter class="solr.PositionFilterFactory"/>
   </analyzer>
 </fieldType>
Copy Field                                   PLONE CONFERENCE 2011




 <copyField source="SearchableText" dest="spell"/>
 <copyField source="SearchableText" dest="substring"/>
PLONE CONFERENCE 2011




Character Filters
• Process text before tokenizing
• Remove irrelevant characters
Pattern Replace                                    PLONE CONFERENCE 2011




 <charFilter class="solr.PatternReplaceCharFilterFactory"
     pattern="[^a-zA-z0-9_-]" replacement="" replace="all"/>

'That WAS a narrow escape!' said Alice, a good deal frightened

  That WAS a narrow escape said Alice a good deal frightened
Mapping                                      PLONE CONFERENCE 2011




  <charFilter class="solr.MappingCharFilterFactory"
      mapping="mapping.txt"/>




  # œ => oe
  "u0153" => "oe"
  # ß => ss
  "u00DF" => "ss"
HTML Strip                                    PLONE CONFERENCE 2011




 <charFilter class="solr.HTMLStripCharFilterFactory"/>
PLONE CONFERENCE 2011




Tokenizers
• Split raw text into tokens / terms
• Typically the first step
Whitespace Tokenizer                              PLONE CONFERENCE 2011




  <tokenizer class="solr.WhitespaceTokenizerFactory"/>

         'That WAS a narrow escape!' said Alice

                       'That
                       WAS
                       a
                       narrow
                       escape!'
                       said
                       Alice
ICU Tokenizer                                   PLONE CONFERENCE 2011




   <tokenizer class="solr.ICUTokenizerFactory"/>

       'That WAS a narrow escape!' said Alice

                     That
                     WAS
                     a
                     narrow
                     escape
                     said
                     Alice
Pattern Tokenizer                                PLONE CONFERENCE 2011




<tokenizer class="solr.PatternTokenizerFactory" pattern=";s*" />

                         one; two; three

                              one
                              two
                              three
Path Hierarchy                                PLONE CONFERENCE 2011




 <tokenizer class="solr.PathHierarchyTokenizerFactory"/>

                  /usr/local/etc/nginx


                  /usr
                  /usr/local
                  /usr/local/etc
                  /usr/local/etc/nginx
PLONE CONFERENCE 2011




Token Filters
• Process after tokenizing
• Normalization of terms
Lower Case                                  PLONE CONFERENCE 2011




   <filter class="solr.LowerCaseFilterFactory"/>

                        Foo
                        bAr
                        BAZ


                        foo
                        bar
                        baz
ASCII Folding                                PLONE CONFERENCE 2011




   <filter class="solr.ASCIIFoldingFilterFactory"/>

                       idée
                       bête
                       grüßen


                       idee
                       bete
                       grussen
ICU Folding                                 PLONE CONFERENCE 2011




   <filter class="solr.ICUFoldingFilterFactory"/>

                      Idée
                      BÊTE
                      GrüßeN


                      idee
                      bete
                      grussen
Pattern Replace                                 PLONE CONFERENCE 2011




<filter class="solr.PatternReplaceFilterFactory"
    pattern="[^a-zA-z0-9_-]" replacement="" replace="all"/>
                   'That         That
                   WAS           WAS
                   a             a
                   narrow        narrow
                   escape!'      escape
                   said          said
                   Alice         Alice
Word Delimiter                                              PLONE CONFERENCE 2011




<filter class="solr.WordDelimiterFilterFactory"
    splitOnCaseChange="1" splitOnNumerics="1" stemEnglishPossessive="1"
    generateWordParts="1" generateNumberParts="1"
    catenateWords="0" catenateNumbers="0" catenateAll="0"
    preserveOriginal="1"/>


                                          StudlyCaps1234-5678
                                          Caps
             StudlyCaps1234-5678          Studly
                                          1234
                                          5678
Edge N Gram                                  PLONE CONFERENCE 2011




 <filter class="solr.EdgeNGramFilterFactory"
     minGramSize="4" maxGramSize="100" side="front"/>

                       Conqueror


                       Conqueror
                       Conquero
                       Conquer
                       Conque
                       Conqu
                       Conq
Stop Words                                  PLONE CONFERENCE 2011




   <filter class="solr.StopFilterFactory"
       ignoreCase="true" words="stopwords.txt"/>

           That                narrow
           WAS                 escape
           a                   said
           narrow              Alice
           escape              good
           said                deal
           Alice               frightened
           a
           good
           deal
           frightened
Synonyms                                          PLONE CONFERENCE 2011




<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
    ignoreCase="true" expand="true"/>


   # synonyms.txt                                   foozball
                                        foosball    foosball
   # add multiple terms                             baby-foot
   foozball, foosball, baby-foot
                                        tele        television
   # merge into one                     t.v.        television
   tv, t.v., tele => television         tv          television
Language Stemming                           PLONE CONFERENCE 2011




  <filter class="solr.EnglishPorterFilterFactory"
      protected="protwords.txt"/>


               dry            dri
               drying         dri
               dried          dri
Language Stemming                                          PLONE CONFERENCE 2011


<filter class="solr.ElisionFilterFactory" articles="stopwordarticles.txt"/>
                  qu'il                    il
                  ne                       ne
                  comprend                 comprend
                  pas                      pas
                  l'anglais                anglais

<filter class="solr.EnglishPorterFilterFactory" language="French"/>

                  considere                consider
                  consideres               consider
                  considerent              consider
Solr Debugging
Schema Browser   PLONE CONFERENCE 2011
Analysis   PLONE CONFERENCE 2011
Analysis   PLONE CONFERENCE 2011
Analysis   PLONE CONFERENCE 2011
Analysis   PLONE CONFERENCE 2011
Analysis   PLONE CONFERENCE 2011
Search Interface   PLONE CONFERENCE 2011
Crafting a URL                                  PLONE CONFERENCE 2011



 http://localhost:8983/solr/select?
 qf=SearchableText^1.0&rows=10&fl=*,score&debugQuery=on&
 explainOther=True&indent=true&defType=dismax&q=test


      q=test
      qf=SearchableText^1.0
      defType=dismax

      debugQuery=on
      explainOther=on
      indent=on
Verbose XML*                                           PLONE CONFERENCE 2011




                  <lst name="responseHeader">
                    <int name="status">0</int>
                    <int name="QTime">2</int>
                    <lst name="params">
                      <str name="explainOther">True</str>
                      <str name="fl">*,score</str>
                      <str name="debugQuery">on</str>
                      <str name="indent">true</str>
                      <str name="q">test</str>
                      <str name="qf">SearchableText^1.0</str>
                      <str name="rows">10</str>
                      <str name="defType">dismax</str>
                    </lst>
                  </lst>



* like there is any other kind
Verbose XML*                                                PLONE CONFERENCE 2011




       <result name="response" numFound="2" start="0" maxScore="0.70710677">
         <doc>
           <float name="score">0.70710677</float>
           <int name="docid">-643919099</int>
         </doc>
         <doc>
           <float name="score">0.3788861</float>
           <int name="docid">-643919097</int>
         </doc>
       </result>




* like there is any other kind
Verbose XML*
<lst name="debug">
                                                             PLONE CONFERENCE 2011


  <str name="rawquerystring">test</str>
  <str name="querystring">test</str>
  <str name="parsedquery">+DisjunctionMaxQuery((SearchableText:test)) ()</str>
  <str name="parsedquery_toString">+(SearchableText:test) ()</str>
  <lst name="explain">
    <str name="-643919099">
0.70710677 = (MATCH) sum of:
  0.70710677 = (MATCH) fieldWeight(SearchableText:test in 4), product of:
    1.4142135 = tf(termFreq(SearchableText:test)=2)
    1.0 = idf(docFreq=5, maxDocs=6)
    0.5 = fieldNorm(field=SearchableText, doc=4)
    </str>
    <str name="-643919097">
0.3788861 = (MATCH) sum of:
  0.3788861 = (MATCH) fieldWeight(SearchableText:test in 0), product of:
    1.7320508 = tf(termFreq(SearchableText:test)=3)
    1.0 = idf(docFreq=5, maxDocs=6)
    0.21875 = fieldNorm(field=SearchableText, doc=0)
    </str>
</lst>


* like there is any other kind
Links                                                                   PLONE CONFERENCE 2011




• Solr (http://lucene.apache.org/solr)


• Solr Wiki     (http://wiki.apache.org/solr)


• Books   (http://www.packtpub.com/books/all?keys=solr)


• SolrIndex     (http://pypi.python.org/pypi/alm.solrindex/)


• collective.solr       (http://pypi.python.org/pypi/collective.solr)
Flickr Credits                                                          PLONE CONFERENCE 2011




•   http://www.flickr.com/photos/naturegeak/5642083189/ (who)

•   http://www.flickr.com/photos/eklektikos/2541408630/ (schema)

•   http://www.flickr.com/photos/sidelong/13954593/ (char filter)

•   http://www.flickr.com/photos/benimoto/2214240119/ (tokenizers)

•   http://www.flickr.com/photos/chaunceydavis/3264077445/ (filters)

•   http://www.flickr.com/photos/comedynose/3271760209/ (configuration)

•   http://www.flickr.com/photos/nicksart/4821509371/ (debugging)




    Thanks to
Questions?




   Check out
           .co m/d emos
 s ixfeetup

Weitere ähnliche Inhalte

Ähnlich wie Make Plone Search Act Like Google Using Solr

Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
Erik Hatcher
 
Behavior Driven Development and Wordpress Plugins
Behavior Driven Development and Wordpress PluginsBehavior Driven Development and Wordpress Plugins
Behavior Driven Development and Wordpress Plugins
djcp
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
Erik Hatcher
 

Ähnlich wie Make Plone Search Act Like Google Using Solr (20)

Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Behavior Driven Development and Wordpress Plugins
Behavior Driven Development and Wordpress PluginsBehavior Driven Development and Wordpress Plugins
Behavior Driven Development and Wordpress Plugins
 
Solr02 fields
Solr02 fieldsSolr02 fields
Solr02 fields
 
Solr Masterclass Bangkok, June 2014
Solr Masterclass Bangkok, June 2014Solr Masterclass Bangkok, June 2014
Solr Masterclass Bangkok, June 2014
 
Beyond full-text searches with Lucene and Solr
Beyond full-text searches with Lucene and SolrBeyond full-text searches with Lucene and Solr
Beyond full-text searches with Lucene and Solr
 
Python and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super ToolsPython and EM CLI: The Enterprise Management Super Tools
Python and EM CLI: The Enterprise Management Super Tools
 
Linux Shell Scripting Craftsmanship
Linux Shell Scripting CraftsmanshipLinux Shell Scripting Craftsmanship
Linux Shell Scripting Craftsmanship
 
Custom EOAdaptors and ERSolr
Custom EOAdaptors and ERSolrCustom EOAdaptors and ERSolr
Custom EOAdaptors and ERSolr
 
Apache Solr + ajax solr
Apache Solr + ajax solrApache Solr + ajax solr
Apache Solr + ajax solr
 
Solr a.b-ab
Solr a.b-abSolr a.b-ab
Solr a.b-ab
 
How fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapeHow fluentd fits into the modern software landscape
How fluentd fits into the modern software landscape
 
2010 Smith Scripting101
2010 Smith Scripting1012010 Smith Scripting101
2010 Smith Scripting101
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기
 
Solr introduction
Solr introductionSolr introduction
Solr introduction
 
Migration from FAST ESP to Solr
Migration from FAST ESP to SolrMigration from FAST ESP to Solr
Migration from FAST ESP to Solr
 
APOC Pearls - Whirlwind Tour Through the Neo4j APOC Procedures Library
APOC Pearls - Whirlwind Tour Through the Neo4j APOC Procedures LibraryAPOC Pearls - Whirlwind Tour Through the Neo4j APOC Procedures Library
APOC Pearls - Whirlwind Tour Through the Neo4j APOC Procedures Library
 
JSFI - Dynamic RCP Desktop Application
JSFI - Dynamic RCP Desktop ApplicationJSFI - Dynamic RCP Desktop Application
JSFI - Dynamic RCP Desktop Application
 
Solr Anti Patterns
Solr Anti PatternsSolr Anti Patterns
Solr Anti Patterns
 
Solr Anti - patterns
Solr Anti - patternsSolr Anti - patterns
Solr Anti - patterns
 

Mehr von Clayton Parker

Pioneer a Strategic Change in Content Organization with Plone
Pioneer a Strategic Change in Content Organization with PlonePioneer a Strategic Change in Content Organization with Plone
Pioneer a Strategic Change in Content Organization with Plone
Clayton Parker
 

Mehr von Clayton Parker (20)

Customizing Your Shell With Dotfiles
Customizing Your Shell With DotfilesCustomizing Your Shell With Dotfiles
Customizing Your Shell With Dotfiles
 
Vim for Mere Mortals
Vim for Mere MortalsVim for Mere Mortals
Vim for Mere Mortals
 
Fuzzy Feelings for Fuzzy Matching
Fuzzy Feelings for Fuzzy MatchingFuzzy Feelings for Fuzzy Matching
Fuzzy Feelings for Fuzzy Matching
 
Exploring Code with Pry!
Exploring Code with Pry!Exploring Code with Pry!
Exploring Code with Pry!
 
Zen and the Art of Python
Zen and the Art of PythonZen and the Art of Python
Zen and the Art of Python
 
So you think you can pdb?
So you think you can pdb?So you think you can pdb?
So you think you can pdb?
 
Managing Chaos: Merging 120 Sites into a single Plone Multisite Solution
Managing Chaos: Merging 120 Sites into a single Plone Multisite SolutionManaging Chaos: Merging 120 Sites into a single Plone Multisite Solution
Managing Chaos: Merging 120 Sites into a single Plone Multisite Solution
 
Current State of Python Packaging
Current State of Python PackagingCurrent State of Python Packaging
Current State of Python Packaging
 
Notre Dame Seamless Syndication with Lineage
Notre Dame Seamless Syndication with LineageNotre Dame Seamless Syndication with Lineage
Notre Dame Seamless Syndication with Lineage
 
Pioneer a Strategic Change in Content Organization with Plone
Pioneer a Strategic Change in Content Organization with PlonePioneer a Strategic Change in Content Organization with Plone
Pioneer a Strategic Change in Content Organization with Plone
 
Using Buildout, GenericSetup and a Policy Package to Rule the World
Using Buildout, GenericSetup and a Policy Package to Rule the WorldUsing Buildout, GenericSetup and a Policy Package to Rule the World
Using Buildout, GenericSetup and a Policy Package to Rule the World
 
Migrating from drupal to plone with transmogrifier
Migrating from drupal to plone with transmogrifierMigrating from drupal to plone with transmogrifier
Migrating from drupal to plone with transmogrifier
 
Buildout for the Future
Buildout for the FutureBuildout for the Future
Buildout for the Future
 
Buildout future
Buildout futureBuildout future
Buildout future
 
Laying Pipe with Transmogrifier
Laying Pipe with TransmogrifierLaying Pipe with Transmogrifier
Laying Pipe with Transmogrifier
 
LDAP and Active Directory Authentication in Plone
LDAP and Active Directory Authentication in PloneLDAP and Active Directory Authentication in Plone
LDAP and Active Directory Authentication in Plone
 
Code with Style - PyOhio
Code with Style - PyOhioCode with Style - PyOhio
Code with Style - PyOhio
 
Code with style
Code with styleCode with style
Code with style
 
Using Buildout to Develop and Deploy Python Projects
Using Buildout to Develop and Deploy Python ProjectsUsing Buildout to Develop and Deploy Python Projects
Using Buildout to Develop and Deploy Python Projects
 
Generic Setup De-Mystified
Generic Setup De-MystifiedGeneric Setup De-Mystified
Generic Setup De-Mystified
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Make Plone Search Act Like Google Using Solr

  • 1. Make Plone Search Act Like Google Using Solr Clayton Parker | Senior Web Developer PLONE CONFERENCE 2011
  • 3. What will we learn? PLONE CONFERENCE 2011
  • 4. What will we learn? PLONE CONFERENCE 2011 • Intro to Solr
  • 5. What will we learn? PLONE CONFERENCE 2011 • Intro to Solr • Brief overview of Plone integration points
  • 6. What will we learn? PLONE CONFERENCE 2011 • Intro to Solr • Brief overview of Plone integration points • Solr configuration
  • 7. What will we learn? PLONE CONFERENCE 2011 • Intro to Solr • Brief overview of Plone integration points • Solr configuration • Solr schema setup
  • 8. What will we learn? PLONE CONFERENCE 2011 • Intro to Solr • Brief overview of Plone integration points • Solr configuration • Solr schema setup • Debugging tips and tricks
  • 10. Version Madness PLONE CONFERENCE 2011 1.x (up to 1.4) 1.5 (number abandoned) 3.x (merge of Lucene and Solr)
  • 11. Books PLONE CONFERENCE 2011
  • 16. Query Handlers PLONE CONFERENCE 2011 • Standard • Disjunction Max (DisMax) • Extended DisMax (experimental)
  • 17. DisMax PLONE CONFERENCE 2011 • Multiple index searches • Boosting • Friendlier to end users
  • 18. DisMax PLONE CONFERENCE 2011 Index Name qf=SearchableText^1.0 substring^0.2 Weight
  • 19. MinShouldMatch PLONE CONFERENCE 2011 mm=100% All terms required mm=50% Half of the terms required mm=-2 All but two terms required
  • 20. MinShouldMatch PLONE CONFERENCE 2011 mm=2<-25% 9<-3 2 or less 3-9 terms all more than 9 terms are but 25% terms all but required required three are required
  • 21. Spelling Component PLONE CONFERENCE 2011 <searchComponent name="spellcheck" class="solr.SpellCheckComponent"> <lst name="spellchecker"> <str name="name">default</str> <str name="classname">solr.IndexBasedSpellChecker</str> <str name="buildOnCommit">true</str> <str name="spellcheckIndexDir">path/to/spellcheck</str> <!-- The field that will contain the dynamic spelling data --> <str name="field">spell</str> <str name="accuracy">0.5</str> </lst> <!-- Control indexing and query of spelling data --> <str name="queryAnalyzerFieldType">spell-text</str> </searchComponent>
  • 22. Spelling Schema PLONE CONFERENCE 2011 <fieldType name="spell-text" class="solr.TextField"> <analyzer> <tokenizer class="solr.ICUTokenizerFactory"/> <filter class="solr.ICUFoldingFilterFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/> </analyzer> </fieldType>
  • 24. Index vs Query PLONE CONFERENCE 2011 http://www.cominvent.com/2011/04/04/solr-architecture-diagram/
  • 27. PLONE CONFERENCE 2011 Character Filters Tokenizer
  • 28. PLONE CONFERENCE 2011 Character Filters Tokenizer Filters
  • 29. PLONE CONFERENCE 2011 Character Filters Tokenizer Filters
  • 30. Complete Field PLONE CONFERENCE 2011 <fieldType name="text" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <charFilter class="solr.MappingCharFilterFactory" mapping="mapping.txt"/> <tokenizer class="solr.ICUTokenizerFactory"/> <filter class="solr.ICUFoldingFilterFactory"/> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/> <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/> <filter class="solr.WordDelimiterFilterFactory" splitOnCaseChange="1" splitOnNumerics="1" stemEnglishPossessive="1" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" preserveOriginal="1"/> </analyzer> <analyzer type="query"> <charFilter class="solr.MappingCharFilterFactory" mapping="mapping.txt"/> <tokenizer class="solr.ICUTokenizerFactory"/> <filter class="solr.ICUFoldingFilterFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/> <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/> <filter class="solr.WordDelimiterFilterFactory" splitOnCaseChange="1" splitOnNumerics="1" stemEnglishPossessive="1" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" preserveOriginal="1"/> <filter class="solr.PositionFilterFactory"/> </analyzer> </fieldType>
  • 31. Copy Field PLONE CONFERENCE 2011 <copyField source="SearchableText" dest="spell"/> <copyField source="SearchableText" dest="substring"/>
  • 32. PLONE CONFERENCE 2011 Character Filters • Process text before tokenizing • Remove irrelevant characters
  • 33. Pattern Replace PLONE CONFERENCE 2011 <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="[^a-zA-z0-9_-]" replacement="" replace="all"/> 'That WAS a narrow escape!' said Alice, a good deal frightened That WAS a narrow escape said Alice a good deal frightened
  • 34. Mapping PLONE CONFERENCE 2011 <charFilter class="solr.MappingCharFilterFactory" mapping="mapping.txt"/> # œ => oe "u0153" => "oe" # ß => ss "u00DF" => "ss"
  • 35. HTML Strip PLONE CONFERENCE 2011 <charFilter class="solr.HTMLStripCharFilterFactory"/>
  • 36. PLONE CONFERENCE 2011 Tokenizers • Split raw text into tokens / terms • Typically the first step
  • 37. Whitespace Tokenizer PLONE CONFERENCE 2011 <tokenizer class="solr.WhitespaceTokenizerFactory"/> 'That WAS a narrow escape!' said Alice 'That WAS a narrow escape!' said Alice
  • 38. ICU Tokenizer PLONE CONFERENCE 2011 <tokenizer class="solr.ICUTokenizerFactory"/> 'That WAS a narrow escape!' said Alice That WAS a narrow escape said Alice
  • 39. Pattern Tokenizer PLONE CONFERENCE 2011 <tokenizer class="solr.PatternTokenizerFactory" pattern=";s*" /> one; two; three one two three
  • 40. Path Hierarchy PLONE CONFERENCE 2011 <tokenizer class="solr.PathHierarchyTokenizerFactory"/> /usr/local/etc/nginx /usr /usr/local /usr/local/etc /usr/local/etc/nginx
  • 41. PLONE CONFERENCE 2011 Token Filters • Process after tokenizing • Normalization of terms
  • 42. Lower Case PLONE CONFERENCE 2011 <filter class="solr.LowerCaseFilterFactory"/> Foo bAr BAZ foo bar baz
  • 43. ASCII Folding PLONE CONFERENCE 2011 <filter class="solr.ASCIIFoldingFilterFactory"/> idée bête grüßen idee bete grussen
  • 44. ICU Folding PLONE CONFERENCE 2011 <filter class="solr.ICUFoldingFilterFactory"/> Idée BÊTE GrüßeN idee bete grussen
  • 45. Pattern Replace PLONE CONFERENCE 2011 <filter class="solr.PatternReplaceFilterFactory" pattern="[^a-zA-z0-9_-]" replacement="" replace="all"/> 'That That WAS WAS a a narrow narrow escape!' escape said said Alice Alice
  • 46. Word Delimiter PLONE CONFERENCE 2011 <filter class="solr.WordDelimiterFilterFactory" splitOnCaseChange="1" splitOnNumerics="1" stemEnglishPossessive="1" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" preserveOriginal="1"/> StudlyCaps1234-5678 Caps StudlyCaps1234-5678 Studly 1234 5678
  • 47. Edge N Gram PLONE CONFERENCE 2011 <filter class="solr.EdgeNGramFilterFactory" minGramSize="4" maxGramSize="100" side="front"/> Conqueror Conqueror Conquero Conquer Conque Conqu Conq
  • 48. Stop Words PLONE CONFERENCE 2011 <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/> That narrow WAS escape a said narrow Alice escape good said deal Alice frightened a good deal frightened
  • 49. Synonyms PLONE CONFERENCE 2011 <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> # synonyms.txt foozball foosball foosball # add multiple terms baby-foot foozball, foosball, baby-foot tele television # merge into one t.v. television tv, t.v., tele => television tv television
  • 50. Language Stemming PLONE CONFERENCE 2011 <filter class="solr.EnglishPorterFilterFactory" protected="protwords.txt"/> dry dri drying dri dried dri
  • 51. Language Stemming PLONE CONFERENCE 2011 <filter class="solr.ElisionFilterFactory" articles="stopwordarticles.txt"/> qu'il il ne ne comprend comprend pas pas l'anglais anglais <filter class="solr.EnglishPorterFilterFactory" language="French"/> considere consider consideres consider considerent consider
  • 53. Schema Browser PLONE CONFERENCE 2011
  • 54. Analysis PLONE CONFERENCE 2011
  • 55. Analysis PLONE CONFERENCE 2011
  • 56. Analysis PLONE CONFERENCE 2011
  • 57. Analysis PLONE CONFERENCE 2011
  • 58. Analysis PLONE CONFERENCE 2011
  • 59. Search Interface PLONE CONFERENCE 2011
  • 60. Crafting a URL PLONE CONFERENCE 2011 http://localhost:8983/solr/select? qf=SearchableText^1.0&rows=10&fl=*,score&debugQuery=on& explainOther=True&indent=true&defType=dismax&q=test q=test qf=SearchableText^1.0 defType=dismax debugQuery=on explainOther=on indent=on
  • 61. Verbose XML* PLONE CONFERENCE 2011 <lst name="responseHeader"> <int name="status">0</int> <int name="QTime">2</int> <lst name="params"> <str name="explainOther">True</str> <str name="fl">*,score</str> <str name="debugQuery">on</str> <str name="indent">true</str> <str name="q">test</str> <str name="qf">SearchableText^1.0</str> <str name="rows">10</str> <str name="defType">dismax</str> </lst> </lst> * like there is any other kind
  • 62. Verbose XML* PLONE CONFERENCE 2011 <result name="response" numFound="2" start="0" maxScore="0.70710677"> <doc> <float name="score">0.70710677</float> <int name="docid">-643919099</int> </doc> <doc> <float name="score">0.3788861</float> <int name="docid">-643919097</int> </doc> </result> * like there is any other kind
  • 63. Verbose XML* <lst name="debug"> PLONE CONFERENCE 2011 <str name="rawquerystring">test</str> <str name="querystring">test</str> <str name="parsedquery">+DisjunctionMaxQuery((SearchableText:test)) ()</str> <str name="parsedquery_toString">+(SearchableText:test) ()</str> <lst name="explain"> <str name="-643919099"> 0.70710677 = (MATCH) sum of: 0.70710677 = (MATCH) fieldWeight(SearchableText:test in 4), product of: 1.4142135 = tf(termFreq(SearchableText:test)=2) 1.0 = idf(docFreq=5, maxDocs=6) 0.5 = fieldNorm(field=SearchableText, doc=4) </str> <str name="-643919097"> 0.3788861 = (MATCH) sum of: 0.3788861 = (MATCH) fieldWeight(SearchableText:test in 0), product of: 1.7320508 = tf(termFreq(SearchableText:test)=3) 1.0 = idf(docFreq=5, maxDocs=6) 0.21875 = fieldNorm(field=SearchableText, doc=0) </str> </lst> * like there is any other kind
  • 64. Links PLONE CONFERENCE 2011 • Solr (http://lucene.apache.org/solr) • Solr Wiki (http://wiki.apache.org/solr) • Books (http://www.packtpub.com/books/all?keys=solr) • SolrIndex (http://pypi.python.org/pypi/alm.solrindex/) • collective.solr (http://pypi.python.org/pypi/collective.solr)
  • 65. Flickr Credits PLONE CONFERENCE 2011 • http://www.flickr.com/photos/naturegeak/5642083189/ (who) • http://www.flickr.com/photos/eklektikos/2541408630/ (schema) • http://www.flickr.com/photos/sidelong/13954593/ (char filter) • http://www.flickr.com/photos/benimoto/2214240119/ (tokenizers) • http://www.flickr.com/photos/chaunceydavis/3264077445/ (filters) • http://www.flickr.com/photos/comedynose/3271760209/ (configuration) • http://www.flickr.com/photos/nicksart/4821509371/ (debugging) Thanks to
  • 66. Questions? Check out .co m/d emos s ixfeetup