SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
Lucene for Solr
  Developers
      uberconf - July 14, 2011
     Presented by Erik Hatcher
erik.hatcher@lucidimagination.com
         Lucid Imagination
 http://www.lucidimagination.com
Lucene Core
• IndexWriter
• Directory
• IndexReader, IndexSearcher
• analysis: Analyzer, TokenStream,
  Tokenizer,TokenFilter
• Query
Solr Architecture
Customizing - Don't do it!

•   Unless you need to.
•   In other words... ensure you've given the built-in
    capabilities a try, asked on the e-mail list, and
    spelunked into at least Solr's code a bit to make
    some sense of the situation.
•   But we're here to roll up our sleeves, because we
    need to...
But first...
•   Look at Lucene and/or Solr source code as
    appropriate

•   Carefully read javadocs and wiki pages - lots of tips
    there

•   And, hey, search for what you're trying to do...

    •   Google, of course

    •   But try out LucidFind and other Lucene ecosystem
        specific search systems -
        http://www.lucidimagination.com/search/
Extension points
•   Tokenizer, TokenFilter,   •   QParser
    CharFilter
                              •   DataImportHandler
•   SearchComponent               hooks

•   RequestHandler                •   data sources

•   ResponseWriter                •   entity processors

•   FieldType                     •   transformers

•   Similarity                •   several others
Factories
• FooFactory (most) everywhere.
  Sometimes there's BarPlugin style

• for sake of discussion... let's just skip the
  "factory" part
• In Solr, Factories and Plugins are used by
  configuration loading to parameterize and
  construct
"Installing" plugins
• Compile .java to .class, JAR it up
• Put JAR files in either:
 • <solr-home>/lib
 • a shared lib when using multicore
 • anywhere, and register location in
    solrconfig.xml
• Hook in plugins as appropriate
Multicore sharedLib

<solr sharedLib="/usr/local/solr/customlib"
       persistent="true">
   <cores adminPath="/admin/cores">
      <core instanceDir="core1" name="core1"/>
      <core instanceDir="core2" name="core2"/>
   </cores>
</solr>
Plugins via
        solrconfig.xml


• <lib dir="/path/to/your/custom/jars" />
Analysis

• CharFilter
• Tokenizer
• TokenFilter
Primer

• Tokens, Terms
• Attributes: Type, Payloads, Offsets,
  Positions, Term Vectors
• part of the picture:
Version

• enum:
 • Version.LUCENE_31,
    Version.LUCENE_32, etc
• Version.onOrAfter(Version other)
CharFilter
• extend BaseCharFilter
• enables pre-tokenization filtering/morphing
  of incoming field value
• only affects tokenization, not stored value
• Built-in CharFilters: HTMLStripCharFilter,
  PatternReplaceCharFilter, and
  MappingCharFilter
Tokenizer
•   common to extend CharTokenizer

•   implement -

    •   protected abstract boolean isTokenChar(int c);

•   optionally override -

    •   protected int normalize(int c)

•   extend Tokenizer directly for finer control

•   Popular built-in Tokenizers include: WhitespaceTokenizer,
    StandardTokenizer, PatternTokenizer, KeywordTokenizer,
    ICUTokenizer
TokenFilter

• a TokenStream whose input is another
  TokenStream
• Popular TokenFilters include:
  LowerCaseFilter, CommonGramsFilter,
  SnowballFilter, StopFilter,
  WordDelimiterFilter
Lucene's analysis APIs
• tricky business, what with Attributes
  (Source/Factory's), State, characters, code
  points,Version, etc...
• Test!!!
 • BaseTokenStreamTestCase
 • Look at Lucene and Solr's test cases
Solr's Analysis Tools

• Admin analysis tool
• Field analysis request handler
• DEMO
Query Parsing


• String -> org.apache.lucene.search.Query
QParserPlugin
public abstract class QParserPlugin
    implements NamedListInitializedPlugin {

    public abstract QParser createParser(
      String qstr,
      SolrParams localParams,
      SolrParams params,
      SolrQueryRequest req);
}
QParser
public abstract class QParser {

    public abstract Query parse()
              throws ParseException;

}
Built-in QParsers
from QParserPlugin.java
  /** internal use - name to class mappings of builtin parsers */
  public static final Object[] standardPlugins = {
     LuceneQParserPlugin.NAME, LuceneQParserPlugin.class,
     OldLuceneQParserPlugin.NAME, OldLuceneQParserPlugin.class,
     FunctionQParserPlugin.NAME, FunctionQParserPlugin.class,
     PrefixQParserPlugin.NAME, PrefixQParserPlugin.class,
     BoostQParserPlugin.NAME, BoostQParserPlugin.class,
     DisMaxQParserPlugin.NAME, DisMaxQParserPlugin.class,
     ExtendedDismaxQParserPlugin.NAME, ExtendedDismaxQParserPlugin.class,
     FieldQParserPlugin.NAME, FieldQParserPlugin.class,
     RawQParserPlugin.NAME, RawQParserPlugin.class,
     TermQParserPlugin.NAME, TermQParserPlugin.class,
     NestedQParserPlugin.NAME, NestedQParserPlugin.class,
     FunctionRangeQParserPlugin.NAME, FunctionRangeQParserPlugin.class,
     SpatialFilterQParserPlugin.NAME, SpatialFilterQParserPlugin.class,
     SpatialBoxQParserPlugin.NAME, SpatialBoxQParserPlugin.class,
     JoinQParserPlugin.NAME, JoinQParserPlugin.class,
  };
Local Parameters

• {!qparser_name param=value}expression
 • or
• {!qparser_name param=value v=expression}
• Can substitute $references from request
  parameters
Param Substitution
solrconfig.xml
<requestHandler name="/document"
                class="solr.SearchHandler">
  <lst name="invariants">
    <str name="q">{!term f=id v=$id}</str>
  </lst>
</requestHandler>

Solr request
http://localhost:8983/solr/document?id=FOO37
Custom QParser

• Implement a QParserPlugin that creates your
  custom QParser
• Register in solrconfig.xml
 • <queryParser name="myparser"
    class="com.mycompany.MyQParserPlugin"/>
Update Processor

• Responsible for handling these commands:
 • add/update
 • delete
 • commit
 • merge indexes
Built-in Update
            Processors
•   RunUpdateProcessor
    •   Actually performs the operations, such as
        adding the documents to the index
•   LogUpdateProcessor
    •   Logs each operation
•   SignatureUpdateProcessor
    •   duplicate detection and optionally rejection
UIMA Update
           Processor
•   UIMA - Unstructured Information Management
    Architecture - http://uima.apache.org/

•   Enables UIMA components to augment
    documents

•   Entity extraction, automated categorization,
    language detection, etc

•   "contrib" plugin

•   http://wiki.apache.org/solr/SolrUIMA
Update Processor
         Chain
• UpdateProcessor's sequence into a chain
• Each processor can abort the entire update
  or hand processing to next processor in
  the chain
• Chains, of update processor factories, are
  specified in solrconfig.xml
• Update requests can specify an
  update.processor parameter
Default update
            processor chain
From SolrCore.java
// construct the default chain
UpdateRequestProcessorFactory[] factories =
  new UpdateRequestProcessorFactory[]{
     new RunUpdateProcessorFactory(),
     new LogUpdateProcessorFactory()
  };

    Note: these steps have been swapped on trunk recently
Example Update
           Processor
•   What are the best facets to show for a particular
    query? Wouldn't it be nice to see the distribution of
    document "attributes" represented across a result
    set?

•   Learned this trick from the Smithsonian, who were
    doing it manually - add an indexed field containing the
    field names of the interesting other fields on the
    document.

•   Facet on that field "of field names" initially, then
    request facets on the top values returned.
Config for custom
           update processor
<updateRequestProcessorChain name="fields_used" default="true">
 <processor class="solr.processor.FieldsUsedUpdateProcessorFactory">
  <str name="fieldsUsedFieldName">attribute_fields</str>
  <str name="fieldNameRegex">.*_attribute</str>
 </processor>
 <processor class="solr.LogUpdateProcessorFactory" />
 <processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
FieldsUsedUpdateProcessorFactory


public class FieldsUsedUpdateProcessorFactory extends UpdateRequestProcessorFactory {
 private String fieldsUsedFieldName;
 private Pattern fieldNamePattern;

    public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp,
                                                                  UpdateRequestProcessor next) {
      return new FieldsUsedUpdateProcessor(req, rsp, this, next);
    }

    // ... next slide ...

}
FieldsUsedUpdateProcessorFactory
 @Override
 public void init(NamedList args) {
  if (args == null) return;

     SolrParams params = SolrParams.toSolrParams(args);

     fieldsUsedFieldName = params.get("fieldsUsedFieldName");
     if (fieldsUsedFieldName == null) {
       throw new SolrException
          (SolrException.ErrorCode.SERVER_ERROR,
             "fieldsUsedFieldName must be specified");
     }

     // TODO check that fieldsUsedFieldName is a valid field name and multiValued

     String fieldNameRegex = params.get("fieldNameRegex");
     if (fieldNameRegex == null) {
       throw new SolrException
          (SolrException.ErrorCode.SERVER_ERROR,
             "fieldNameRegex must be specified");
     }
     fieldNamePattern = Pattern.compile(fieldNameRegex);

     super.init(args);
 }
class FieldsUsedUpdateProcessor extends UpdateRequestProcessor {
  public FieldsUsedUpdateProcessor(SolrQueryRequest req,
                                   SolrQueryResponse rsp,
                                   FieldsUsedUpdateProcessorFactory factory,
                                   UpdateRequestProcessor next) {
    super(next);
  }

    @Override
    public void processAdd(AddUpdateCommand cmd) throws IOException {
      SolrInputDocument doc = cmd.getSolrInputDocument();

        Collection<String> incomingFieldNames = doc.getFieldNames();

        Iterator<String> iterator = incomingFieldNames.iterator();
        ArrayList<String> usedFields = new ArrayList<String>();
        while (iterator.hasNext()) {
          String f = iterator.next();
          if (fieldNamePattern.matcher(f).matches()) {
            usedFields.add(f);
          }
        }

        doc.addField(fieldsUsedFieldName, usedFields.toArray());
        super.processAdd(cmd);
    }
}
FieldsUsedUpdateProcessor
          in action
schema.xml
  <dynamicField name="*_attribute" type="string" indexed="true" stored="true" multiValued="true"/>

Add some documents
solr.add([{:id=>1, :name => "Big Blue Shoes", :size_attribute => 'L', :color_attribute => 'Blue'},
          {:id=>2, :name => "Cool Gizmo", :memory_attribute => "16GB", :color_attribute => 'White'}])
solr.commit

Facet on attribute_fields
 - http://localhost:8983/solr/select?q=*:*&facet=on&facet.field=attribute_fields&wt=json&indent=on
      "facet_fields":{
          "attribute_fields":[
             "color_attribute",2,
             "memory_attribute",1,
             "size_attribute",1]}
Search Components
• Built-in: Clustering, Debug, Facet, Highlight,
  MoreLikeThis, Query, QueryElevation,
  SpellCheck, Stats, TermVector, Terms
• Non-distributed API:
 • prepare(ResponseBuilder rb)
 • process(ResponseBuilder rb)
Example - auto facet
          select
•   It sure would be nice if you could have Solr automatically
    select field(s) for faceting based dynamically off the
    profile of the results. For example, you're indexing
    disparate types of products, all with varying attributes
    (color, size - like for apparel, memory_size - for
    electronics, subject - for books, etc), and a user searches
    for "ipod" where most products match products with
    color and memory_size attributes... let's automatically
    facet on those fields.

•   https://issues.apache.org/jira/browse/SOLR-2641
AutoFacetSelection
       Component
•   Too much code for a slide, let's take a look in
    an IDE...

•   Basically -

    •   process() gets autofacet.field and autofacet.n
        request params, facets on field, takes top N
        values, sets those as facet.field's

    •   Gotcha - need to call rb.setNeedDocSet
        (true) in prepare() as faceting needs it
SearchComponent
              config
<searchComponent name="autofacet"
     class="solr.AutoFacetSelectionComponent"/>
<requestHandler name="/searchplus"
                class="solr.SearchHandler">
  <arr name="components">
    <str>query</str>
    <str>autofacet</str>
    <str>facet</str>
    <str>debug</str>
  </arr>
</requestHandler>
autofacet success
http://localhost:8983/solr/searchplus
?q=*:*&facet=on&autofacet.field=attribute_fields&wt=json&indent=on
{
  "response":{"numFound":2,"start":0,"docs":[
       {
         "size_attribute":["L"],
         "color_attribute":["Blue"],
         "name":"Big Blue Shoes",
         "id":"1",
         "attribute_fields":["size_attribute",
           "color_attribute"]},
       {
         "color_attribute":["White"],
         "name":"Cool Gizmo",
         "memory_attribute":["16GB"],
         "id":"2",
         "attribute_fields":["color_attribute",
           "memory_attribute"]}]
  },
  "facet_counts":{
     "facet_queries":{},
     "facet_fields":{
       "color_attribute":[
         "Blue",1,
         "White",1],
       "memory_attribute":[
         "16GB",1]}}}
Distributed-aware
    SearchComponents
•   SearchComponent has a few distributed mode
    methods:

    •   distributedProcess(ResponseBuilder)

    •   modifyRequest(ResponseBuilder rb,
        SearchComponent who, ShardRequest sreq)

    •   handleResponses(ResponseBuilder rb,
        ShardRequest sreq)

    •   finishStage(ResponseBuilder rb)
Testing

• AbstractSolrTestCase
• SolrTestCaseJ4
• SolrMeter
 • http://code.google.com/p/solrmeter/
For more information...
•   http://www.lucidimagination.com

•   LucidFind

    •   search Lucene ecosystem: mailing lists, wikis, JIRA, etc

    •   http://search.lucidimagination.com

•   Getting started with LucidWorks Enterprise:

    •   http://www.lucidimagination.com/products/
        lucidworks-search-platform/enterprise

•   http://lucene.apache.org/solr - wiki, e-mail lists
Thank You!

Más contenido relacionado

La actualidad más candente

Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachAlexandre Rafalovitch
 
Apache Solr! Enterprise Search Solutions at your Fingertips!
Apache Solr! Enterprise Search Solutions at your Fingertips!Apache Solr! Enterprise Search Solutions at your Fingertips!
Apache Solr! Enterprise Search Solutions at your Fingertips!Murshed Ahmmad Khan
 
Ingesting and Manipulating Data with JavaScript
Ingesting and Manipulating Data with JavaScriptIngesting and Manipulating Data with JavaScript
Ingesting and Manipulating Data with JavaScriptLucidworks
 
Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Erik Hatcher
 
Solr Powered Lucene
Solr Powered LuceneSolr Powered Lucene
Solr Powered LuceneErik Hatcher
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with SolrErik Hatcher
 
Apache Solr - Enterprise search platform
Apache Solr - Enterprise search platformApache Solr - Enterprise search platform
Apache Solr - Enterprise search platformTommaso Teofili
 
Rapid Solr Schema Development (Phone directory)
Rapid Solr Schema Development (Phone directory)Rapid Solr Schema Development (Phone directory)
Rapid Solr Schema Development (Phone directory)Alexandre Rafalovitch
 
Apache Solr Workshop
Apache Solr WorkshopApache Solr Workshop
Apache Solr WorkshopJSGB
 
code4lib 2011 preconference: What's New in Solr (since 1.4.1)
code4lib 2011 preconference: What's New in Solr (since 1.4.1)code4lib 2011 preconference: What's New in Solr (since 1.4.1)
code4lib 2011 preconference: What's New in Solr (since 1.4.1)Erik Hatcher
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solrlucenerevolution
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 
Building your own search engine with Apache Solr
Building your own search engine with Apache SolrBuilding your own search engine with Apache Solr
Building your own search engine with Apache SolrBiogeeks
 
From content to search: speed-dating Apache Solr (ApacheCON 2018)
From content to search: speed-dating Apache Solr (ApacheCON 2018)From content to search: speed-dating Apache Solr (ApacheCON 2018)
From content to search: speed-dating Apache Solr (ApacheCON 2018)Alexandre Rafalovitch
 
Solr Query Parsing
Solr Query ParsingSolr Query Parsing
Solr Query ParsingErik Hatcher
 

La actualidad más candente (20)

Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
 
Apache Solr! Enterprise Search Solutions at your Fingertips!
Apache Solr! Enterprise Search Solutions at your Fingertips!Apache Solr! Enterprise Search Solutions at your Fingertips!
Apache Solr! Enterprise Search Solutions at your Fingertips!
 
Ingesting and Manipulating Data with JavaScript
Ingesting and Manipulating Data with JavaScriptIngesting and Manipulating Data with JavaScript
Ingesting and Manipulating Data with JavaScript
 
JSON in Solr: from top to bottom
JSON in Solr: from top to bottomJSON in Solr: from top to bottom
JSON in Solr: from top to bottom
 
Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)
 
Solr Powered Lucene
Solr Powered LuceneSolr Powered Lucene
Solr Powered Lucene
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Solr Recipes
Solr RecipesSolr Recipes
Solr Recipes
 
Apache Solr - Enterprise search platform
Apache Solr - Enterprise search platformApache Solr - Enterprise search platform
Apache Solr - Enterprise search platform
 
Rapid Solr Schema Development (Phone directory)
Rapid Solr Schema Development (Phone directory)Rapid Solr Schema Development (Phone directory)
Rapid Solr Schema Development (Phone directory)
 
Apache Solr Workshop
Apache Solr WorkshopApache Solr Workshop
Apache Solr Workshop
 
Apache Solr Workshop
Apache Solr WorkshopApache Solr Workshop
Apache Solr Workshop
 
code4lib 2011 preconference: What's New in Solr (since 1.4.1)
code4lib 2011 preconference: What's New in Solr (since 1.4.1)code4lib 2011 preconference: What's New in Solr (since 1.4.1)
code4lib 2011 preconference: What's New in Solr (since 1.4.1)
 
Solr Masterclass Bangkok, June 2014
Solr Masterclass Bangkok, June 2014Solr Masterclass Bangkok, June 2014
Solr Masterclass Bangkok, June 2014
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Building your own search engine with Apache Solr
Building your own search engine with Apache SolrBuilding your own search engine with Apache Solr
Building your own search engine with Apache Solr
 
From content to search: speed-dating Apache Solr (ApacheCON 2018)
From content to search: speed-dating Apache Solr (ApacheCON 2018)From content to search: speed-dating Apache Solr (ApacheCON 2018)
From content to search: speed-dating Apache Solr (ApacheCON 2018)
 
Solr Query Parsing
Solr Query ParsingSolr Query Parsing
Solr Query Parsing
 

Destacado

Multi-language Content Discovery Through Entity Driven Search: Presented by A...
Multi-language Content Discovery Through Entity Driven Search: Presented by A...Multi-language Content Discovery Through Entity Driven Search: Presented by A...
Multi-language Content Discovery Through Entity Driven Search: Presented by A...Lucidworks
 
Deep Data at Macy's - Searching Hierarchichal Documents for eCommerce Merchan...
Deep Data at Macy's - Searching Hierarchichal Documents for eCommerce Merchan...Deep Data at Macy's - Searching Hierarchichal Documents for eCommerce Merchan...
Deep Data at Macy's - Searching Hierarchichal Documents for eCommerce Merchan...Lucidworks
 
Solr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabs
Solr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabsSolr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabs
Solr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabsLucidworks
 
Lucene/Solr Revolution 2015 Opening Keynote with Lucidworks CEO Will Hayes
Lucene/Solr Revolution 2015 Opening Keynote with Lucidworks CEO Will HayesLucene/Solr Revolution 2015 Opening Keynote with Lucidworks CEO Will Hayes
Lucene/Solr Revolution 2015 Opening Keynote with Lucidworks CEO Will HayesLucidworks
 
Secure Search - Using Apache Sentry to Add Authentication and Authorization S...
Secure Search - Using Apache Sentry to Add Authentication and Authorization S...Secure Search - Using Apache Sentry to Add Authentication and Authorization S...
Secure Search - Using Apache Sentry to Add Authentication and Authorization S...Lucidworks
 
Search Analytics Component: Presented by Steven Bower, Bloomberg L.P.
Search Analytics Component: Presented by Steven Bower, Bloomberg L.P.Search Analytics Component: Presented by Steven Bower, Bloomberg L.P.
Search Analytics Component: Presented by Steven Bower, Bloomberg L.P.Lucidworks
 
Galene - LinkedIn's Search Architecture: Presented by Diego Buthay & Sriram S...
Galene - LinkedIn's Search Architecture: Presented by Diego Buthay & Sriram S...Galene - LinkedIn's Search Architecture: Presented by Diego Buthay & Sriram S...
Galene - LinkedIn's Search Architecture: Presented by Diego Buthay & Sriram S...Lucidworks
 
Building a Real-Time News Search Engine: Presented by Ramkumar Aiyengar, Bloo...
Building a Real-Time News Search Engine: Presented by Ramkumar Aiyengar, Bloo...Building a Real-Time News Search Engine: Presented by Ramkumar Aiyengar, Bloo...
Building a Real-Time News Search Engine: Presented by Ramkumar Aiyengar, Bloo...Lucidworks
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrLucidworks (Archived)
 

Destacado (10)

Multi-language Content Discovery Through Entity Driven Search: Presented by A...
Multi-language Content Discovery Through Entity Driven Search: Presented by A...Multi-language Content Discovery Through Entity Driven Search: Presented by A...
Multi-language Content Discovery Through Entity Driven Search: Presented by A...
 
Deep Data at Macy's - Searching Hierarchichal Documents for eCommerce Merchan...
Deep Data at Macy's - Searching Hierarchichal Documents for eCommerce Merchan...Deep Data at Macy's - Searching Hierarchichal Documents for eCommerce Merchan...
Deep Data at Macy's - Searching Hierarchichal Documents for eCommerce Merchan...
 
Solr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabs
Solr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabsSolr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabs
Solr Distributed Indexing in WalmartLabs: Presented by Shengua Wan, WalmartLabs
 
Lucene/Solr Revolution 2015 Opening Keynote with Lucidworks CEO Will Hayes
Lucene/Solr Revolution 2015 Opening Keynote with Lucidworks CEO Will HayesLucene/Solr Revolution 2015 Opening Keynote with Lucidworks CEO Will Hayes
Lucene/Solr Revolution 2015 Opening Keynote with Lucidworks CEO Will Hayes
 
Secure Search - Using Apache Sentry to Add Authentication and Authorization S...
Secure Search - Using Apache Sentry to Add Authentication and Authorization S...Secure Search - Using Apache Sentry to Add Authentication and Authorization S...
Secure Search - Using Apache Sentry to Add Authentication and Authorization S...
 
Search Analytics Component: Presented by Steven Bower, Bloomberg L.P.
Search Analytics Component: Presented by Steven Bower, Bloomberg L.P.Search Analytics Component: Presented by Steven Bower, Bloomberg L.P.
Search Analytics Component: Presented by Steven Bower, Bloomberg L.P.
 
Galene - LinkedIn's Search Architecture: Presented by Diego Buthay & Sriram S...
Galene - LinkedIn's Search Architecture: Presented by Diego Buthay & Sriram S...Galene - LinkedIn's Search Architecture: Presented by Diego Buthay & Sriram S...
Galene - LinkedIn's Search Architecture: Presented by Diego Buthay & Sriram S...
 
Building a Real-Time News Search Engine: Presented by Ramkumar Aiyengar, Bloo...
Building a Real-Time News Search Engine: Presented by Ramkumar Aiyengar, Bloo...Building a Real-Time News Search Engine: Presented by Ramkumar Aiyengar, Bloo...
Building a Real-Time News Search Engine: Presented by Ramkumar Aiyengar, Bloo...
 
Solr4 nosql search_server_2013
Solr4 nosql search_server_2013Solr4 nosql search_server_2013
Solr4 nosql search_server_2013
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with Solr
 

Similar a Lucene for Solr Developers

Apache Solr crash course
Apache Solr crash courseApache Solr crash course
Apache Solr crash courseTommaso Teofili
 
Apache Solr 1.4 – Faster, Easier, and More Versatile than Ever
Apache Solr 1.4 – Faster, Easier, and More Versatile than EverApache Solr 1.4 – Faster, Easier, and More Versatile than Ever
Apache Solr 1.4 – Faster, Easier, and More Versatile than EverLucidworks (Archived)
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrJayesh Bhoyar
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginsearchbox-com
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrErik Hatcher
 
Developing a Real-time Engine with Akka, Cassandra, and Spray
Developing a Real-time Engine with Akka, Cassandra, and SprayDeveloping a Real-time Engine with Akka, Cassandra, and Spray
Developing a Real-time Engine with Akka, Cassandra, and SprayJacob Park
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrErik Hatcher
 
IT talk SPb "Full text search for lazy guys"
IT talk SPb "Full text search for lazy guys" IT talk SPb "Full text search for lazy guys"
IT talk SPb "Full text search for lazy guys" DataArt
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Viral Solani
 
Robotframework
RobotframeworkRobotframework
RobotframeworkElla Sun
 
Apache Solr + ajax solr
Apache Solr + ajax solrApache Solr + ajax solr
Apache Solr + ajax solrNet7
 
ERRest - Designing a good REST service
ERRest - Designing a good REST serviceERRest - Designing a good REST service
ERRest - Designing a good REST serviceWO Community
 
Code transformation With Spoon
Code transformation With SpoonCode transformation With Spoon
Code transformation With SpoonGérard Paligot
 
Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxMichael Hackstein
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformationLars Marius Garshol
 

Similar a Lucene for Solr Developers (20)

Apache Solr crash course
Apache Solr crash courseApache Solr crash course
Apache Solr crash course
 
Apache solr liferay
Apache solr liferayApache solr liferay
Apache solr liferay
 
Apache Solr 1.4 – Faster, Easier, and More Versatile than Ever
Apache Solr 1.4 – Faster, Easier, and More Versatile than EverApache Solr 1.4 – Faster, Easier, and More Versatile than Ever
Apache Solr 1.4 – Faster, Easier, and More Versatile than Ever
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component plugin
 
ERRest in Depth
ERRest in DepthERRest in Depth
ERRest in Depth
 
Solr a.b-ab
Solr a.b-abSolr a.b-ab
Solr a.b-ab
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
Developing a Real-time Engine with Akka, Cassandra, and Spray
Developing a Real-time Engine with Akka, Cassandra, and SprayDeveloping a Real-time Engine with Akka, Cassandra, and Spray
Developing a Real-time Engine with Akka, Cassandra, and Spray
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
IT talk SPb "Full text search for lazy guys"
IT talk SPb "Full text search for lazy guys" IT talk SPb "Full text search for lazy guys"
IT talk SPb "Full text search for lazy guys"
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)
 
Robotframework
RobotframeworkRobotframework
Robotframework
 
ERRest and Dojo
ERRest and DojoERRest and Dojo
ERRest and Dojo
 
Apache Solr + ajax solr
Apache Solr + ajax solrApache Solr + ajax solr
Apache Solr + ajax solr
 
ERRest - Designing a good REST service
ERRest - Designing a good REST serviceERRest - Designing a good REST service
ERRest - Designing a good REST service
 
Code transformation With Spoon
Code transformation With SpoonCode transformation With Spoon
Code transformation With Spoon
 
Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB Foxx
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 

Más de Erik Hatcher

Solr Powered Libraries
Solr Powered LibrariesSolr Powered Libraries
Solr Powered LibrariesErik Hatcher
 
"Solr Update" at code4lib '13 - Chicago
"Solr Update" at code4lib '13 - Chicago"Solr Update" at code4lib '13 - Chicago
"Solr Update" at code4lib '13 - ChicagoErik Hatcher
 
Query Parsing - Tips and Tricks
Query Parsing - Tips and TricksQuery Parsing - Tips and Tricks
Query Parsing - Tips and TricksErik Hatcher
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrErik Hatcher
 
What's New in Solr 3.x / 4.0
What's New in Solr 3.x / 4.0What's New in Solr 3.x / 4.0
What's New in Solr 3.x / 4.0Erik Hatcher
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development TutorialErik Hatcher
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with SolrErik Hatcher
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with SolrErik Hatcher
 
Solr Flair: Search User Interfaces Powered by Apache Solr (ApacheCon US 2009,...
Solr Flair: Search User Interfaces Powered by Apache Solr (ApacheCon US 2009,...Solr Flair: Search User Interfaces Powered by Apache Solr (ApacheCon US 2009,...
Solr Flair: Search User Interfaces Powered by Apache Solr (ApacheCon US 2009,...Erik Hatcher
 
Solr Flair: Search User Interfaces Powered by Apache Solr
Solr Flair: Search User Interfaces Powered by Apache SolrSolr Flair: Search User Interfaces Powered by Apache Solr
Solr Flair: Search User Interfaces Powered by Apache SolrErik Hatcher
 

Más de Erik Hatcher (13)

Ted Talk
Ted TalkTed Talk
Ted Talk
 
Solr Payloads
Solr PayloadsSolr Payloads
Solr Payloads
 
Solr Powered Libraries
Solr Powered LibrariesSolr Powered Libraries
Solr Powered Libraries
 
"Solr Update" at code4lib '13 - Chicago
"Solr Update" at code4lib '13 - Chicago"Solr Update" at code4lib '13 - Chicago
"Solr Update" at code4lib '13 - Chicago
 
Query Parsing - Tips and Tricks
Query Parsing - Tips and TricksQuery Parsing - Tips and Tricks
Query Parsing - Tips and Tricks
 
Solr 4
Solr 4Solr 4
Solr 4
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
What's New in Solr 3.x / 4.0
What's New in Solr 3.x / 4.0What's New in Solr 3.x / 4.0
What's New in Solr 3.x / 4.0
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development Tutorial
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Solr Flair: Search User Interfaces Powered by Apache Solr (ApacheCon US 2009,...
Solr Flair: Search User Interfaces Powered by Apache Solr (ApacheCon US 2009,...Solr Flair: Search User Interfaces Powered by Apache Solr (ApacheCon US 2009,...
Solr Flair: Search User Interfaces Powered by Apache Solr (ApacheCon US 2009,...
 
Solr Flair: Search User Interfaces Powered by Apache Solr
Solr Flair: Search User Interfaces Powered by Apache SolrSolr Flair: Search User Interfaces Powered by Apache Solr
Solr Flair: Search User Interfaces Powered by Apache Solr
 

Último

Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 

Último (20)

Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 

Lucene for Solr Developers

  • 1. Lucene for Solr Developers uberconf - July 14, 2011 Presented by Erik Hatcher erik.hatcher@lucidimagination.com Lucid Imagination http://www.lucidimagination.com
  • 2. Lucene Core • IndexWriter • Directory • IndexReader, IndexSearcher • analysis: Analyzer, TokenStream, Tokenizer,TokenFilter • Query
  • 4. Customizing - Don't do it! • Unless you need to. • In other words... ensure you've given the built-in capabilities a try, asked on the e-mail list, and spelunked into at least Solr's code a bit to make some sense of the situation. • But we're here to roll up our sleeves, because we need to...
  • 5. But first... • Look at Lucene and/or Solr source code as appropriate • Carefully read javadocs and wiki pages - lots of tips there • And, hey, search for what you're trying to do... • Google, of course • But try out LucidFind and other Lucene ecosystem specific search systems - http://www.lucidimagination.com/search/
  • 6. Extension points • Tokenizer, TokenFilter, • QParser CharFilter • DataImportHandler • SearchComponent hooks • RequestHandler • data sources • ResponseWriter • entity processors • FieldType • transformers • Similarity • several others
  • 7. Factories • FooFactory (most) everywhere. Sometimes there's BarPlugin style • for sake of discussion... let's just skip the "factory" part • In Solr, Factories and Plugins are used by configuration loading to parameterize and construct
  • 8. "Installing" plugins • Compile .java to .class, JAR it up • Put JAR files in either: • <solr-home>/lib • a shared lib when using multicore • anywhere, and register location in solrconfig.xml • Hook in plugins as appropriate
  • 9. Multicore sharedLib <solr sharedLib="/usr/local/solr/customlib" persistent="true"> <cores adminPath="/admin/cores"> <core instanceDir="core1" name="core1"/> <core instanceDir="core2" name="core2"/> </cores> </solr>
  • 10. Plugins via solrconfig.xml • <lib dir="/path/to/your/custom/jars" />
  • 12. Primer • Tokens, Terms • Attributes: Type, Payloads, Offsets, Positions, Term Vectors • part of the picture:
  • 13. Version • enum: • Version.LUCENE_31, Version.LUCENE_32, etc • Version.onOrAfter(Version other)
  • 14. CharFilter • extend BaseCharFilter • enables pre-tokenization filtering/morphing of incoming field value • only affects tokenization, not stored value • Built-in CharFilters: HTMLStripCharFilter, PatternReplaceCharFilter, and MappingCharFilter
  • 15. Tokenizer • common to extend CharTokenizer • implement - • protected abstract boolean isTokenChar(int c); • optionally override - • protected int normalize(int c) • extend Tokenizer directly for finer control • Popular built-in Tokenizers include: WhitespaceTokenizer, StandardTokenizer, PatternTokenizer, KeywordTokenizer, ICUTokenizer
  • 16. TokenFilter • a TokenStream whose input is another TokenStream • Popular TokenFilters include: LowerCaseFilter, CommonGramsFilter, SnowballFilter, StopFilter, WordDelimiterFilter
  • 17. Lucene's analysis APIs • tricky business, what with Attributes (Source/Factory's), State, characters, code points,Version, etc... • Test!!! • BaseTokenStreamTestCase • Look at Lucene and Solr's test cases
  • 18. Solr's Analysis Tools • Admin analysis tool • Field analysis request handler • DEMO
  • 19. Query Parsing • String -> org.apache.lucene.search.Query
  • 20. QParserPlugin public abstract class QParserPlugin implements NamedListInitializedPlugin { public abstract QParser createParser( String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req); }
  • 21. QParser public abstract class QParser { public abstract Query parse() throws ParseException; }
  • 22. Built-in QParsers from QParserPlugin.java /** internal use - name to class mappings of builtin parsers */ public static final Object[] standardPlugins = { LuceneQParserPlugin.NAME, LuceneQParserPlugin.class, OldLuceneQParserPlugin.NAME, OldLuceneQParserPlugin.class, FunctionQParserPlugin.NAME, FunctionQParserPlugin.class, PrefixQParserPlugin.NAME, PrefixQParserPlugin.class, BoostQParserPlugin.NAME, BoostQParserPlugin.class, DisMaxQParserPlugin.NAME, DisMaxQParserPlugin.class, ExtendedDismaxQParserPlugin.NAME, ExtendedDismaxQParserPlugin.class, FieldQParserPlugin.NAME, FieldQParserPlugin.class, RawQParserPlugin.NAME, RawQParserPlugin.class, TermQParserPlugin.NAME, TermQParserPlugin.class, NestedQParserPlugin.NAME, NestedQParserPlugin.class, FunctionRangeQParserPlugin.NAME, FunctionRangeQParserPlugin.class, SpatialFilterQParserPlugin.NAME, SpatialFilterQParserPlugin.class, SpatialBoxQParserPlugin.NAME, SpatialBoxQParserPlugin.class, JoinQParserPlugin.NAME, JoinQParserPlugin.class, };
  • 23. Local Parameters • {!qparser_name param=value}expression • or • {!qparser_name param=value v=expression} • Can substitute $references from request parameters
  • 24. Param Substitution solrconfig.xml <requestHandler name="/document" class="solr.SearchHandler"> <lst name="invariants"> <str name="q">{!term f=id v=$id}</str> </lst> </requestHandler> Solr request http://localhost:8983/solr/document?id=FOO37
  • 25. Custom QParser • Implement a QParserPlugin that creates your custom QParser • Register in solrconfig.xml • <queryParser name="myparser" class="com.mycompany.MyQParserPlugin"/>
  • 26. Update Processor • Responsible for handling these commands: • add/update • delete • commit • merge indexes
  • 27. Built-in Update Processors • RunUpdateProcessor • Actually performs the operations, such as adding the documents to the index • LogUpdateProcessor • Logs each operation • SignatureUpdateProcessor • duplicate detection and optionally rejection
  • 28. UIMA Update Processor • UIMA - Unstructured Information Management Architecture - http://uima.apache.org/ • Enables UIMA components to augment documents • Entity extraction, automated categorization, language detection, etc • "contrib" plugin • http://wiki.apache.org/solr/SolrUIMA
  • 29. Update Processor Chain • UpdateProcessor's sequence into a chain • Each processor can abort the entire update or hand processing to next processor in the chain • Chains, of update processor factories, are specified in solrconfig.xml • Update requests can specify an update.processor parameter
  • 30. Default update processor chain From SolrCore.java // construct the default chain UpdateRequestProcessorFactory[] factories = new UpdateRequestProcessorFactory[]{ new RunUpdateProcessorFactory(), new LogUpdateProcessorFactory() }; Note: these steps have been swapped on trunk recently
  • 31. Example Update Processor • What are the best facets to show for a particular query? Wouldn't it be nice to see the distribution of document "attributes" represented across a result set? • Learned this trick from the Smithsonian, who were doing it manually - add an indexed field containing the field names of the interesting other fields on the document. • Facet on that field "of field names" initially, then request facets on the top values returned.
  • 32. Config for custom update processor <updateRequestProcessorChain name="fields_used" default="true"> <processor class="solr.processor.FieldsUsedUpdateProcessorFactory"> <str name="fieldsUsedFieldName">attribute_fields</str> <str name="fieldNameRegex">.*_attribute</str> </processor> <processor class="solr.LogUpdateProcessorFactory" /> <processor class="solr.RunUpdateProcessorFactory" /> </updateRequestProcessorChain>
  • 33. FieldsUsedUpdateProcessorFactory public class FieldsUsedUpdateProcessorFactory extends UpdateRequestProcessorFactory { private String fieldsUsedFieldName; private Pattern fieldNamePattern; public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) { return new FieldsUsedUpdateProcessor(req, rsp, this, next); } // ... next slide ... }
  • 34. FieldsUsedUpdateProcessorFactory @Override public void init(NamedList args) { if (args == null) return; SolrParams params = SolrParams.toSolrParams(args); fieldsUsedFieldName = params.get("fieldsUsedFieldName"); if (fieldsUsedFieldName == null) { throw new SolrException (SolrException.ErrorCode.SERVER_ERROR, "fieldsUsedFieldName must be specified"); } // TODO check that fieldsUsedFieldName is a valid field name and multiValued String fieldNameRegex = params.get("fieldNameRegex"); if (fieldNameRegex == null) { throw new SolrException (SolrException.ErrorCode.SERVER_ERROR, "fieldNameRegex must be specified"); } fieldNamePattern = Pattern.compile(fieldNameRegex); super.init(args); }
  • 35. class FieldsUsedUpdateProcessor extends UpdateRequestProcessor { public FieldsUsedUpdateProcessor(SolrQueryRequest req, SolrQueryResponse rsp, FieldsUsedUpdateProcessorFactory factory, UpdateRequestProcessor next) { super(next); } @Override public void processAdd(AddUpdateCommand cmd) throws IOException { SolrInputDocument doc = cmd.getSolrInputDocument(); Collection<String> incomingFieldNames = doc.getFieldNames(); Iterator<String> iterator = incomingFieldNames.iterator(); ArrayList<String> usedFields = new ArrayList<String>(); while (iterator.hasNext()) { String f = iterator.next(); if (fieldNamePattern.matcher(f).matches()) { usedFields.add(f); } } doc.addField(fieldsUsedFieldName, usedFields.toArray()); super.processAdd(cmd); } }
  • 36. FieldsUsedUpdateProcessor in action schema.xml <dynamicField name="*_attribute" type="string" indexed="true" stored="true" multiValued="true"/> Add some documents solr.add([{:id=>1, :name => "Big Blue Shoes", :size_attribute => 'L', :color_attribute => 'Blue'}, {:id=>2, :name => "Cool Gizmo", :memory_attribute => "16GB", :color_attribute => 'White'}]) solr.commit Facet on attribute_fields - http://localhost:8983/solr/select?q=*:*&facet=on&facet.field=attribute_fields&wt=json&indent=on "facet_fields":{ "attribute_fields":[ "color_attribute",2, "memory_attribute",1, "size_attribute",1]}
  • 37. Search Components • Built-in: Clustering, Debug, Facet, Highlight, MoreLikeThis, Query, QueryElevation, SpellCheck, Stats, TermVector, Terms • Non-distributed API: • prepare(ResponseBuilder rb) • process(ResponseBuilder rb)
  • 38. Example - auto facet select • It sure would be nice if you could have Solr automatically select field(s) for faceting based dynamically off the profile of the results. For example, you're indexing disparate types of products, all with varying attributes (color, size - like for apparel, memory_size - for electronics, subject - for books, etc), and a user searches for "ipod" where most products match products with color and memory_size attributes... let's automatically facet on those fields. • https://issues.apache.org/jira/browse/SOLR-2641
  • 39. AutoFacetSelection Component • Too much code for a slide, let's take a look in an IDE... • Basically - • process() gets autofacet.field and autofacet.n request params, facets on field, takes top N values, sets those as facet.field's • Gotcha - need to call rb.setNeedDocSet (true) in prepare() as faceting needs it
  • 40. SearchComponent config <searchComponent name="autofacet" class="solr.AutoFacetSelectionComponent"/> <requestHandler name="/searchplus" class="solr.SearchHandler"> <arr name="components"> <str>query</str> <str>autofacet</str> <str>facet</str> <str>debug</str> </arr> </requestHandler>
  • 41. autofacet success http://localhost:8983/solr/searchplus ?q=*:*&facet=on&autofacet.field=attribute_fields&wt=json&indent=on { "response":{"numFound":2,"start":0,"docs":[ { "size_attribute":["L"], "color_attribute":["Blue"], "name":"Big Blue Shoes", "id":"1", "attribute_fields":["size_attribute", "color_attribute"]}, { "color_attribute":["White"], "name":"Cool Gizmo", "memory_attribute":["16GB"], "id":"2", "attribute_fields":["color_attribute", "memory_attribute"]}] }, "facet_counts":{ "facet_queries":{}, "facet_fields":{ "color_attribute":[ "Blue",1, "White",1], "memory_attribute":[ "16GB",1]}}}
  • 42. Distributed-aware SearchComponents • SearchComponent has a few distributed mode methods: • distributedProcess(ResponseBuilder) • modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) • handleResponses(ResponseBuilder rb, ShardRequest sreq) • finishStage(ResponseBuilder rb)
  • 43. Testing • AbstractSolrTestCase • SolrTestCaseJ4 • SolrMeter • http://code.google.com/p/solrmeter/
  • 44. For more information... • http://www.lucidimagination.com • LucidFind • search Lucene ecosystem: mailing lists, wikis, JIRA, etc • http://search.lucidimagination.com • Getting started with LucidWorks Enterprise: • http://www.lucidimagination.com/products/ lucidworks-search-platform/enterprise • http://lucene.apache.org/solr - wiki, e-mail lists