OpenSource Search Engines and LuceneSolr UCSB 290 N
![Open-Source Search Engines and Lucene/Solr UCSB 290 N 2013. Tao Yang Slides are based Open-Source Search Engines and Lucene/Solr UCSB 290 N 2013. Tao Yang Slides are based](https://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-1.jpg)
Open-Source Search Engines and Lucene/Solr UCSB 290 N 2013. Tao Yang Slides are based on Y. Seeley, S. Das, C. Hostetter 1
![Open Source Search Engines • Why? § Low cost: No licensing fees § Source Open Source Search Engines • Why? § Low cost: No licensing fees § Source](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-2.jpg)
Open Source Search Engines • Why? § Low cost: No licensing fees § Source code available for customization § Good for modest or even large data sizes • Challenges: § Performance, Scalability § Maintenance 2
![Open Source Search Engines: Examples • Lucene § A full-text search library with core Open Source Search Engines: Examples • Lucene § A full-text search library with core](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-3.jpg)
Open Source Search Engines: Examples • Lucene § A full-text search library with core indexing and search services § Competitive in engine performance, relevancy, and code maintenance • Solr § based on the Lucene Java search library with XML/HTTP APIs § caching, replication, and a web administration interface. • Lemur/Indri § C++ search engine from U. Mass/CMU 3
![A Comparison of Open Source Search Engines • Middleton/Baeza-Yates 2010 (Modern Information Retrieval. Text A Comparison of Open Source Search Engines • Middleton/Baeza-Yates 2010 (Modern Information Retrieval. Text](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-4.jpg)
A Comparison of Open Source Search Engines • Middleton/Baeza-Yates 2010 (Modern Information Retrieval. Text book)
![A Comparison of Open Source Search Engines for 1. 69 M Pages • Middleton/Baeza-Yates A Comparison of Open Source Search Engines for 1. 69 M Pages • Middleton/Baeza-Yates](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-5.jpg)
A Comparison of Open Source Search Engines for 1. 69 M Pages • Middleton/Baeza-Yates 2010 (Modern Information Retrieval)
![A Comparison of Open Source Search Engines • July 2009, Vik’s blog (http: //zooie. A Comparison of Open Source Search Engines • July 2009, Vik’s blog (http: //zooie.](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-6.jpg)
A Comparison of Open Source Search Engines • July 2009, Vik’s blog (http: //zooie. wordpress. com/2009/07/06/acomparison-of-open-source-search-engines-and-indexing-twitter/)
![A Comparison of Open Source Search Engines • Vik’s blog(http: //zooie. wordpress. com/2009/07/06/a-comparison-of-open-source-search-engines-and-indexing-twitter/) A Comparison of Open Source Search Engines • Vik’s blog(http: //zooie. wordpress. com/2009/07/06/a-comparison-of-open-source-search-engines-and-indexing-twitter/)](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-7.jpg)
A Comparison of Open Source Search Engines • Vik’s blog(http: //zooie. wordpress. com/2009/07/06/a-comparison-of-open-source-search-engines-and-indexing-twitter/)
![Lucene • Developed by Doug Cutting initially – Java-based. Created in 1999, Donated to Lucene • Developed by Doug Cutting initially – Java-based. Created in 1999, Donated to](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-8.jpg)
Lucene • Developed by Doug Cutting initially – Java-based. Created in 1999, Donated to Apache in 2001 • Features § No crawler, No document parsing, No “Page. Rank” • Powered by Lucene – IBM Omnifind Y! Edition, Technorati – Wikipedia, Internet Archive, Linked. In, monster. com • Add documents to an index via Index. Writer § A document is a collection of fields § Flexible text analysis – tokenizers, filters • Search for documents via Index. Searcher Hits = search(Query, Filter, Sort, top. N) • Ranking based on tf * idf similarity with normalization
![Lucene’s input content for indexing Document Field Field Name Value • Logical structure § Lucene’s input content for indexing Document Field Field Name Value • Logical structure §](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-9.jpg)
Lucene’s input content for indexing Document Field Field Name Value • Logical structure § Documents are a collection of fields – Stored verbatim for retrieval with results – Indexed – Tokenized and made searchable § Indexed terms stored in inverted index • Physical structure of inverted index § Multiple documents stored in segments • Index. Writer is interface object for entire index 9
![Example of Inverted Indexing aardvark Little Red Riding Hood hood 0 1 little 0 Example of Inverted Indexing aardvark Little Red Riding Hood hood 0 1 little 0](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-10.jpg)
Example of Inverted Indexing aardvark Little Red Riding Hood hood 0 1 little 0 2 Robin Hood red riding robin 0 0 1 Little Women women zoo 2 0 1 2
![Faceted Search/Browsing Example 11 Faceted Search/Browsing Example 11](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-11.jpg)
Faceted Search/Browsing Example 11
![Indexing Flow Lex. Corp BFG-9000 Whitespace. Tokenizer Lex. Corp BFG-9000 Word. Delimiter. Filter catenate. Indexing Flow Lex. Corp BFG-9000 Whitespace. Tokenizer Lex. Corp BFG-9000 Word. Delimiter. Filter catenate.](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-12.jpg)
Indexing Flow Lex. Corp BFG-9000 Whitespace. Tokenizer Lex. Corp BFG-9000 Word. Delimiter. Filter catenate. Words=1 Lex Corp BFG 9000 Lex. Corp Lowercase. Filter lex corp lexcorp bfg 9000
![Analyzers specify how the text in a field is to be indexed § Options Analyzers specify how the text in a field is to be indexed § Options](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-13.jpg)
Analyzers specify how the text in a field is to be indexed § Options in Lucene – Whitespace. Analyzer § divides text at whitespace – Simple. Analyzer § divides text at non-letters § convert to lower case – Stop. Analyzer § Simple. Analyzer § removes stop words – Standard. Analyzer § good for most European Languages § removes stop words § convert to lower case – Create you own Analyzers 13
![Lucene Index Files: Field infos file (. fnm) Format: Fields. Count Field. Name Field. Lucene Index Files: Field infos file (. fnm) Format: Fields. Count Field. Name Field.](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-14.jpg)
Lucene Index Files: Field infos file (. fnm) Format: Fields. Count Field. Name Field. Bits Fields. Count, <Field. Name, Field. Bits> the number of fields in the index the name of the field in a string a byte and an int where the lowest bit of the byte shows whether the field is indexed, and the int is the id of the term 1, <content, 0 x 01> http: //lucene. apache. org/core/3_6_2/fileformats. html 14
![Lucene Index Files: Term Dictionary file (. tis) Term. Count, Term. Infos <Term, Doc. Lucene Index Files: Term Dictionary file (. tis) Term. Count, Term. Infos <Term, Doc.](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-15.jpg)
Lucene Index Files: Term Dictionary file (. tis) Term. Count, Term. Infos <Term, Doc. Freq> Term <Prefix. Length, Suffix, Field. Num> This file is sorted by Terms are ordered first lexicographically by the term's field name, and within that lexicographically by the term's text Term. Count the number of terms in the documents Term text prefixes are shared. The Prefix. Length is the number of initial characters from the previous term which must be pre-pended to a term's suffix in order to form the term's text. Thus, if the previous term's text was "bone" and the term is "boy", the Prefix. Length is two and the suffix is "y". Field. Number the term's field, whose name is stored in the. fnm file Format: 4, <<0, football, 1>, 2> <<0, penn, 1> <<1, layers, 1> <<0, state, 1>, 2> Document Frequency can be obtained from this file. 15
![Lucene Index Files: Term Info index (. tii) Format: Index. Term. Count, Index. Interval, Lucene Index Files: Term Info index (. tii) Format: Index. Term. Count, Index. Interval,](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-16.jpg)
Lucene Index Files: Term Info index (. tii) Format: Index. Term. Count, Index. Interval, Term. Indices <Term. Info, Index. Delta> This contains every Index. Interval th entry from the. tis file, along with its location in the "tis" file. This is designed to be read entirely into memory and used to provide random access to the "tis" file. Index. Delta determines the position of this term's Term. Info within the. tis file. In particular, it is the difference between the position of this term's entry in that file and the position of the previous term's entry. 4, <football, 1> <penn, 3><layers, 2> <state, 1> 16
![Lucene Index Files: Frequency file (. frq) Format: <Term. Freqs> Term. Freqs Term. Freq Lucene Index Files: Frequency file (. frq) Format: <Term. Freqs> Term. Freqs Term. Freq](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-17.jpg)
Lucene Index Files: Frequency file (. frq) Format: <Term. Freqs> Term. Freqs Term. Freq Doc. Delta, Freq? Term. Freqs are ordered by term (the term is implicit, from the. tis file). Term. Freq entries are ordered by increasing document number. Doc. Delta determines both the document number and the frequency. In particular, Doc. Delta/2 is the difference between this document number and the previous document number (or zero when this is the first document in a Term. Freqs). When Doc. Delta is odd, the frequency is one. When Doc. Delta is even, the frequency is read as the next Int. For example, the Term. Freqs for a term which occurs once in document seven and three times in document eleven would be the following sequence of Ints: 15, 8, 3 <<2, 2, 3> <5> <3, 3>> Term Frequency can be obtained from this file. 17
![Lucene Index Files: Position file (. prx) <Term. Positions> Term. Positions <Positions> Positions <Position. Lucene Index Files: Position file (. prx) <Term. Positions> Term. Positions <Positions> Positions <Position.](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-18.jpg)
Lucene Index Files: Position file (. prx) <Term. Positions> Term. Positions <Positions> Positions <Position. Delta > Term. Positions are ordered by term (the term is implicit, from the. tis file). Positions entries are ordered by increasing document number (the document number is implicit from the. frq file). Position. Delta the difference between the position of the current occurrence in the document and the previous occurrence (or zero, if this is the first occurrence in this document). Format: For example, the Term. Positions for a term which occurs as the fourth term in one document, and as the fifth and ninth term in a subsequent document, would be the following sequence of Ints: 4, 5, 4 <<3, 64> <1>> <<1> <0>> <<0> <2>> <<2> <13>> 18
![Query Syntax and Examples • Terms with fields and phrases § Title: right and Query Syntax and Examples • Terms with fields and phrases § Title: right and](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-19.jpg)
Query Syntax and Examples • Terms with fields and phrases § Title: right and text: go § Title: right and go ( go appears in default field “text”) § Title: “the right way” and go • Proximity – “quick fox”~4 • Wildcard – pla? e (plate or place or plane) – practic* (practice or practically) • Fuzzy (edit distance as similarity) – planting~0. 75 (granting or planning) – roam~ (default is 0. 5)
![Query Syntax and Examples • Range – date: [05072007 TO 05232007] (inclusive) – author: Query Syntax and Examples • Range – date: [05072007 TO 05232007] (inclusive) – author:](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-20.jpg)
Query Syntax and Examples • Range – date: [05072007 TO 05232007] (inclusive) – author: {king TO mason} (exclusive) • Ranking weight boosting ^ § title: “Bell” author: “Hemmingway”^3. 0 § Default boost value 1. May be <1 (e. g 0. 2) • Boolean operators: AND, "+", OR, NOT and "-" § “Linux OS” AND system § Linux OR system, Linux system § +Linux –system • Grouping § Title: (+linux +”operating system”)
![Searching: Example Lex. Corp BFG-9000 Lex corp bfg 9000 Whitespace. Tokenizer Lex. Corp Whitespace. Searching: Example Lex. Corp BFG-9000 Lex corp bfg 9000 Whitespace. Tokenizer Lex. Corp Whitespace.](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-21.jpg)
Searching: Example Lex. Corp BFG-9000 Lex corp bfg 9000 Whitespace. Tokenizer Lex. Corp Whitespace. Tokenizer BFG-9000 Lex Word. Delimiter. Filter catenate. Words=1 Lex Corp BFG 9000 corp bfg 9000 Word. Delimiter. Filter catenate. Words=0 Lex corp bfg 9000 Lex. Corp Lowercase. Filter lex corp bfg Lowercase. Filter 9000 lexcorp A Match! corp bfg 9000
![Searching • Concurrent search query handling: § Multiple searchers at once § Thread safe Searching • Concurrent search query handling: § Multiple searchers at once § Thread safe](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-22.jpg)
Searching • Concurrent search query handling: § Multiple searchers at once § Thread safe • Additions or deletions to index are not reflected in already open searchers § Must be closed and reopened • Use commit or optimize on index. Writer
![Query Processing tan s Con Query Con stan t tim e ta nt t Query Processing tan s Con Query Con stan t tim e ta nt t](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-23.jpg)
Query Processing tan s Con Query Con stan t tim e ta nt t ns Co Term Dictionary (Random file access) ime Field info (in Memory) Term Info Index (in Memory) Constant time e t tim Frequency File (Random file access) Co nst ant tim e Position File (Random file access) 23
![Scoring Function is specified in schema. xml • Similarity score(Q, D) = coord(Q, D) Scoring Function is specified in schema. xml • Similarity score(Q, D) = coord(Q, D)](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-24.jpg)
Scoring Function is specified in schema. xml • Similarity score(Q, D) = coord(Q, D) · query. Norm(Q) · ∑ t in Q ( tf(t in D) · idf(t)2 · t. get. Boost() · norm(D) ) • term-based factors – tf(t in D) : term frequency of term t in document d § default – idf(t): inverse document frequency of term t in the entire corpus § default 24
![Default Scoring Functions for query Q in matching document D • coord(Q, D) = Default Scoring Functions for query Q in matching document D • coord(Q, D) =](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-25.jpg)
Default Scoring Functions for query Q in matching document D • coord(Q, D) = overlap between Q and D / maximum overlap Maximum overlap is the maximum possible length of overlap between Q and D • query. Norm(Q) = 1/sum of square weight½ sum of square weight = q. get. Boost()2 · ∑ t in Q ( idf(t) · t. get. Boost() )2 If t. get. Boost() = 1, q. get. Boost() = 1 Then, sum of square weight = ∑ t in Q ( idf(t) )2 thus, query. Norm(Q) = 1/(∑ t in Q ( idf(t) )2) ½ • norm(D) = 1/number of terms½ (This is the normalization by the total number of terms in a document. Number of terms is the total number of terms appeared in a document D. ) • http: //lucene. apache. org/core/3_6_2/scoring. html 25
![Example: • D 1: hello, please say hello to him. • D 2: say Example: • D 1: hello, please say hello to him. • D 2: say](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-26.jpg)
Example: • D 1: hello, please say hello to him. • D 2: say goodbye • Q: you say hello § coord(Q, D) = overlap between Q and D / maximum overlap – coord(Q, D 1) = 2/3, coord(Q, D 2) = 1/2, § query. Norm(Q) = 1/sum of square weight½ – sum of square weight = q. get. Boost()2 · ∑ t in Q ( idf(t) · t. get. Boost() )2 – t. get. Boost() = 1, q. get. Boost() = 1 – sum of square weight = ∑ t in Q ( idf(t) )2 – query. Norm(Q) = 1/(0. 59452+12) ½ =0. 8596 § tf(t in d) = frequency½ – tf(you, D 1) = 0, tf(say, D 1) = 1, tf(hello, D 1) = 2½ =1. 4142 – tf(you, D 2) = 0, tf(say, D 2) = 1, tf(hello, D 2) = 0 § idf(t) = ln (N/(nj+1)) + 1 – idf(you) = 0, idf(say) = ln(2/(2+1)) + 1 = 0. 5945, idf(hello) = ln(2/(1+1)) +1 = 1 § norm(D) = 1/number of terms½ – norm(D 1) = 1/6½ =0. 4082, norm(D 2) = 1/2½ =0. 7071 § Score(Q, D 1) = 2/3*0. 8596*(1*0. 59452+1. 4142*12)*0. 4082=0. 4135 § Score(Q, D 2) = 1/2*0. 8596*(1*0. 59452)*0. 7071=0. 1074
![Lucene Sub-projects or Related • Nutch § Web crawler with document parsing • Hadoop Lucene Sub-projects or Related • Nutch § Web crawler with document parsing • Hadoop](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-27.jpg)
Lucene Sub-projects or Related • Nutch § Web crawler with document parsing • Hadoop § Distributed file systems and data processing § Implements Map. Reduce • Solr • Zookeeper § Centralized service (directory) with distributed synchronization
![Solr Developed by Yonik Seeley at CNET. Donated to Apache in 2006 Features ◦ Solr Developed by Yonik Seeley at CNET. Donated to Apache in 2006 Features ◦](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-28.jpg)
Solr Developed by Yonik Seeley at CNET. Donated to Apache in 2006 Features ◦ Servlet, Web Administration Interface ◦ XML/HTTP, JSON Interfaces ◦ Faceting, Schema to define types and fields ◦ Highlighting, Caching, Index Replication (Master / Slaves) ◦ Pluggable. Java • Powered by Solr – Netflix, CNET, Smithsonian, Game. Spot, AOL: sports and music – Drupal module
![Architecture of Solr HTTP Request Servlet Update Servlet XML Disjunction Admin Standard Custom XML Architecture of Solr HTTP Request Servlet Update Servlet XML Disjunction Admin Standard Custom XML](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-29.jpg)
Architecture of Solr HTTP Request Servlet Update Servlet XML Disjunction Admin Standard Custom XML Update Interface Request Max Request Response Interface Request Handler Writer Handler Config Schema Caching Solr Core Analysis Concurrency Update Handler Replication Lucene 29
![Application usage of Solr: You. Seer search [Penn. State] Crawling(Heritrix) Indexing/Searching(Solr) Parsing Stop Standard Application usage of Solr: You. Seer search [Penn. State] Crawling(Heritrix) Indexing/Searching(Solr) Parsing Stop Standard](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-30.jpg)
Application usage of Solr: You. Seer search [Penn. State] Crawling(Heritrix) Indexing/Searching(Solr) Parsing Stop Standard Your Analyzer Crawl WWW(Heritrix) TXT parser PDF HTML DOC TXT … PDF parser indexer Solr Documents Index indexer HTML parser er h c You. Seer r a e s Searching searcher File FS System. Crawler 30
![Adding Documents in Solr HTTP POST to /update <add><doc boost=“ 2”> <field name=“article”>05991</field> <field Adding Documents in Solr HTTP POST to /update <add><doc boost=“ 2”> <field name=“article”>05991</field> <field](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-31.jpg)
Adding Documents in Solr HTTP POST to /update <add><doc boost=“ 2”> <field name=“article”>05991</field> <field name=“title”>Apache Solr</field> <field name=“subject”>An intro. . . </field> <field name=“category”>search</field> <field name=“category”>lucene</field> <field name=“body”>Solr is a full. . . </field> </doc></add> 31
![Updating/Deleting Documents • Inserting a document with already present unique. Key will erase the Updating/Deleting Documents • Inserting a document with already present unique. Key will erase the](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-32.jpg)
Updating/Deleting Documents • Inserting a document with already present unique. Key will erase the original • Delete by unique. Key field (e. g Id) <delete><id>05591</id></delete> • Delete by Query (multiple documents) <delete> <query>manufacturer: microsoft</query> </delete> 32
![Commit • <commit/> makes changes visible § closes Index. Writer § removes duplicates § Commit • <commit/> makes changes visible § closes Index. Writer § removes duplicates §](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-33.jpg)
Commit • <commit/> makes changes visible § closes Index. Writer § removes duplicates § opens new Index. Searcher – new. Searcher/first. Searcher events – cache warming – “register” the new Index. Searcher • <optimize/> same as commit, merges all index segments. 33
![Default Query Syntax Lucene Query Syntax 1. 2. 3. 4. 5. 6. 7. mission Default Query Syntax Lucene Query Syntax 1. 2. 3. 4. 5. 6. 7. mission](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-34.jpg)
Default Query Syntax Lucene Query Syntax 1. 2. 3. 4. 5. 6. 7. mission impossible; release. Date desc +mission +impossible –actor: cruise “mission impossible” –actor: cruise title: spiderman^10 description: spiderman description: “spiderman movie”~10 +HDTV +weight: [0 TO 100] Wildcard queries: te? t, te*t, test* 34
![Default Parameters Query Arguments for HTTP GET/POST to /select param q start rows fl Default Parameters Query Arguments for HTTP GET/POST to /select param q start rows fl](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-35.jpg)
Default Parameters Query Arguments for HTTP GET/POST to /select param q start rows fl qt df 35 default description The query 0 Offset into the list of matches 10 Number of documents to return * Stored fields to return standard Query type; maps to query handler (schema) Default field to search
![Search Results http: //localhost: 8983/solr/select? q=video&start=0&rows=2&fl=name, price <response><response. Header><status>0</status> <QTime>1</QTime></response. Header> <result num. Found="16173" Search Results http: //localhost: 8983/solr/select? q=video&start=0&rows=2&fl=name, price <response><response. Header><status>0</status> <QTime>1</QTime></response. Header> <result num. Found="16173"](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-36.jpg)
Search Results http: //localhost: 8983/solr/select? q=video&start=0&rows=2&fl=name, price <response><response. Header><status>0</status> <QTime>1</QTime></response. Header> <result num. Found="16173" start="0"> <doc> <str name="name">Apple 60 GB i. Pod with Video</str> <float name="price">399. 0</float> </doc> <str name="name">ASUS Extreme N 7800 GTX/2 DHTV</str> <float name="price">479. 95</float> </doc> </result> </response> 36
![Schema • Lucene has no notion of a schema § Sorting - string vs. Schema • Lucene has no notion of a schema § Sorting - string vs.](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-37.jpg)
Schema • Lucene has no notion of a schema § Sorting - string vs. numeric § Ranges - val: 42 included in val: [1 TO 5] ? § Lucene Query. Parser has date-range support, but must guess. • Defines fields, their types, properties • Defines unique key field, default search field, Similarity implementation 37
![Field Definitions • Field Attributes: name, type, indexed, stored, multi. Valued, omit. Norms <field Field Definitions • Field Attributes: name, type, indexed, stored, multi. Valued, omit. Norms <field](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-38.jpg)
Field Definitions • Field Attributes: name, type, indexed, stored, multi. Valued, omit. Norms <field name="id“ type="string" indexed="true" stored="true"/> <field name="sku“ type="text. Tight” indexed="true" stored="true"/> <field name="name“ type="text“ indexed="true" stored="true"/> <field name=“reviews“ type="text“ indexed="true“ stored=“false"/> <field name="category“ type="text_ws“ indexed="true" stored="true“ multi. Valued="true"/> Stored means retrievable during search • Dynamic Fields, in the spirit of Lucene! <dynamic. Field name="*_i" type="sint“ indexed="true" stored="true"/> <dynamic. Field name="*_s" type="string“ indexed="true" stored="true"/> <dynamic. Field name="*_t" type="text“ indexed="true" stored="true"/> 38
![Schema: Analyzers <fieldtype name="nametext" class="solr. Text. Field"> <analyzer class="org. apache. lucene. analysis. Whitespace. Analyzer"/> Schema: Analyzers <fieldtype name="nametext" class="solr. Text. Field"> <analyzer class="org. apache. lucene. analysis. Whitespace. Analyzer"/>](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-39.jpg)
Schema: Analyzers <fieldtype name="nametext" class="solr. Text. Field"> <analyzer class="org. apache. lucene. analysis. Whitespace. Analyzer"/> </fieldtype> <fieldtype name="text" class="solr. Text. Field"> <analyzer> <tokenizer class="solr. Standard. Tokenizer. Factory"/> <filter class="solr. Standard. Filter. Factory"/> <filter class="solr. Lower. Case. Filter. Factory"/> <filter class="solr. Stop. Filter. Factory"/> <filter class="solr. Porter. Stem. Filter. Factory"/> </analyzer> </fieldtype> <fieldtype name="myfieldtype" class="solr. Text. Field"> <analyzer> <tokenizer class="solr. Whitespace. Tokenizer. Factory"/> <filter class="solr. Snowball. Porter. Filter. Factory" language="German" /> </analyzer> </fieldtype>
![More example <fieldtype name="text" class="solr. Text. Field"> <analyzer> <tokenizer class="solr. Whitespace. Tokenizer. Factory"/> <filter More example <fieldtype name="text" class="solr. Text. Field"> <analyzer> <tokenizer class="solr. Whitespace. Tokenizer. Factory"/> <filter](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-40.jpg)
More example <fieldtype name="text" class="solr. Text. Field"> <analyzer> <tokenizer class="solr. Whitespace. Tokenizer. Factory"/> <filter class="solr. Lower. Case. Filter. Factory"/> <filter class="solr. Synonym. Filter. Factory" synonyms="synonyms. txt“/> <filter class="solr. Stop. Filter. Factory“ words=“stopwords. txt”/> <filter class="solr. English. Porter. Filter. Factory" protected="protwords. txt"/> </analyzer> </fieldtype> 40
![Search Relevancy Document Analysis Query Analysis Power. Shot SD 500 power-shot sd 500 Whitespace. Search Relevancy Document Analysis Query Analysis Power. Shot SD 500 power-shot sd 500 Whitespace.](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-41.jpg)
Search Relevancy Document Analysis Query Analysis Power. Shot SD 500 power-shot sd 500 Whitespace. Tokenizer Power. Shot SD 500 power-shot Word. Delimiter. Filter catenate. Words=1 Power Shot SD 500 sd 500 Word. Delimiter. Filter catenate. Words=0 power shot sd 500 Power. Shot Lowercase. Filter power shot Lowercase. Filter sd 500 power shot powershot A Match! 41
![copy. Field • Copies one field to another at index time • Usecase: Analyze copy. Field • Copies one field to another at index time • Usecase: Analyze](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-42.jpg)
copy. Field • Copies one field to another at index time • Usecase: Analyze same field different ways § copy into a field with a different analyzer § boost exact-case, exact-punctuation matches § language translations, thesaurus, soundex <field name=“title” type=“text”/> <field name=“title_exact” type=“text_exact” stored=“false”/> <copy. Field source=“title” dest=“title_exact”/> • Usecase: Index multiple fields into single searchable field 42
![Faceted Search/Browsing Example 43 Faceted Search/Browsing Example 43](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-43.jpg)
Faceted Search/Browsing Example 43
![Faceted Search/Browsing computer_type: PC memory: [1 GB TO *] omputer price asc intersection Size() Faceted Search/Browsing computer_type: PC memory: [1 GB TO *] omputer price asc intersection Size()](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-44.jpg)
Faceted Search/Browsing computer_type: PC memory: [1 GB TO *] omputer price asc intersection Size() Search(Query, Filter[], Sort, offset, n) section of ordered results Doc. List Unordered set of all results Doc. Set proc_manu: Intel = 594 proc_manu: AMD = 382 price: [0 TO 500] = 247 price: [500 TO 1000] = 689 manu: Dell = 104 manu: HP = 92 manu: Lenovo = 75 Query Response 44
![High Availability Dynamic HTML Generation Appservers HTTP searc requests Load Balancer Solr Searchers Index High Availability Dynamic HTML Generation Appservers HTTP searc requests Load Balancer Solr Searchers Index](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-45.jpg)
High Availability Dynamic HTML Generation Appservers HTTP searc requests Load Balancer Solr Searchers Index Replication admin queries updates admin terminal Updater Solr Master DB 45
![Distribution+Replication 46 Distribution+Replication 46](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-46.jpg)
Distribution+Replication 46
![Caching Index. Searcher’s view of an index is fixed § Aggressive caching possible § Caching Index. Searcher’s view of an index is fixed § Aggressive caching possible §](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-47.jpg)
Caching Index. Searcher’s view of an index is fixed § Aggressive caching possible § Consistency for multi-query requests • filter. Cache – unordered set of document ids matching a query • result. Cache – ordered subset of document ids matching a query • document. Cache – the stored fields of documents • user. Caches – application specific, custom query handlers 47
![Warming for Speed • Lucene Index. Reader warming § field norms, Field. Cache, tii Warming for Speed • Lucene Index. Reader warming § field norms, Field. Cache, tii](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-48.jpg)
Warming for Speed • Lucene Index. Reader warming § field norms, Field. Cache, tii – the term index • Static Cache warming § Configurable static requests to warm new Searchers • Smart Cache Warming (autowarming) § Using MRU items in the current cache to prepopulate the new cache • Warming in parallel with live requests 48
![Smart Cache Warming Requests On-Deck Solr Index. Searcher 2 User Cache Filter Cache Result Smart Cache Warming Requests On-Deck Solr Index. Searcher 2 User Cache Filter Cache Result](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-49.jpg)
Smart Cache Warming Requests On-Deck Solr Index. Searcher 2 User Cache Filter Cache Result Cache Doc Cache 49 3 Live Requests Registered Solr Index. Searcher Request Handler Regenerator 1 Autowarming User Cache Regenerator Filter Cache Regenerator Result Cache Autowarming – warm n MRU cache keys w/ new Searcher Doc Cache Field Norms
![Web Admin Interface • Show Config, Schema, Distribution info • Query Interface • Statistics Web Admin Interface • Show Config, Schema, Distribution info • Query Interface • Statistics](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-50.jpg)
Web Admin Interface • Show Config, Schema, Distribution info • Query Interface • Statistics § Caches: lookups, hitratio, inserts, evictions, size § Request. Handlers: requests, errors § Update. Handler: adds, deletes, commits, optimizes § Index. Reader, open-time, index-version, num. Docs, max. Docs, • Analysis Debugger § Shows tokens after each Analyzer stage § Shows token matches for query vs index 50
![51 51](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-51.jpg)
51
![References • http: //lucene. apache. org/core/3_6_2/gettingstarted. html • http: //lucene. apache. org/solr/ • http: References • http: //lucene. apache. org/core/3_6_2/gettingstarted. html • http: //lucene. apache. org/solr/ • http:](http://slidetodoc.com/presentation_image/35e30f44a606ce87171abefcd7b09e51/image-52.jpg)
References • http: //lucene. apache. org/core/3_6_2/gettingstarted. html • http: //lucene. apache. org/solr/ • http: //people. apache. org/~yonik/presentations/
- Slides: 52