SlideShare a Scribd company logo
1 of 32
Download to read offline
Query Parsing
Presented by Erik Hatcher
    27 February 2013




                            1
Description

    Interpreting what the user
    meant and what they ideally
    would like to find is tricky
    business. This talk will cover
    useful tips and tricks to better
    leverage and extend Solr's
    analysis and query parsing
    capabilities to more richly parse
    and interpret user queries.

                                        2
Abstract

 In this talk, Solr's built-in query parsers will be
 detailed included when and how to use them. Solr has
 nested query parsing capability, allowing for multiple
 query parsers to be used to generate a single query.
 The nested query parsing feature will be described
 and demonstrated. In many domains, e-commerce in
 particular, parsing queries often means interpreting
 which entities (e.g. products, categories, vehicles) the
 user likely means; this talk will conclude with
 techniques to achieve richer query interpretation.




                                                            3
Query parsers in Solr




                        4
Query Parsers in Solr




                        5
What’s new in 4.x?
    • Surround query parser
    • _query_:”{!...}” ugliness now unnecessary
      - just use nested {!...} expressions
    • Coming to 4.2: "switch" query parser




                                                  6
"lucene"-syntax query parser
    • FieldType awareness
       - range queries, numerics
       - allows date math
       - reverses wildcard terms, if indexing used ReverseWildcardFilter
    • Magic fields
       - _val_: function query injection
       - _query_: nested query, to use a different query parser
    • Multi-term analysis (type="multiterm")
       - Analyzes prefix, wildcard, regex expressions to normalize
            diacritics, lowercase, etc
       - If not explicitly defined, all MultiTermAwareComponent's from
            query analyzer are used, or KeywordTokenizer for effectively
            no analysis



                                                                           7
dismax
   • Simple constrained syntax
       - "supports phrases" +requiredTerms -prohibitedTerms loose terms
   • Spreads terms across specified query fields (qf) and entire query string
        across phrase fields (pf)
       - with field-specific boosting
       - and explicit and implicit phrase slop
       - scores each document with the maximum score for that document as produced by
             any subquery; primary score associated with the highest boost, not the sum of the
             field scores (as BooleanQuery would give)

   • Minimum match (mm) allows query fields gradient between AND and
        OR
       - some number of terms must match, but not all necessarily, and can vary depending
             on number of actual query terms

   • Additive boost queries (bq) and boost functions (bf)
   • Debug output includes parsed boost and function queries



                                                                                                 8
Specifying the query parser
    • defType=parser_name
      - defines main query parser
    • {!parser_name local=param...}expression
      - Can specify parser per query expression
    • These are equivalent:
      - q=ApacheCon NA
         2013&defType=dismax&mm=2&qf=name
      - q={!dismax qf=name mm=2}ApacheCon NA
         2013
      - q={!dismax qf=name mm=2 v='ApacheCon NA
         2013'}

                                                  9
Local Parameter Substitution
    /document?id=13




                               10
Nested Query Parsing
   • Leverages the "lucene" query parser's _query_/{!...} trick
   • Example:
      - q={!dismax qf='title^2 body' v=$user_query} AND
          {!dismax qf='keywords^5 description^2' v=$topic}
      - &user_query=ApacheCon NA 2013
      - &topic=events
   • Setting the complex nested q parameter in a request handler
       can make the client request lean and clean
      - And even qf and other parameters can be substituted:
          • {!dismax qf=$title_qf pf=$title_pf v=$title_query}
          • &title_qf=title^5 subtitle^2...

   • Real world example, Stanford University Libraries:
      - http://searchworks.stanford.edu/advanced
      - Insanely complex sets of nested dismax's and qf/pf settings


                                                                      11
edismax: extended dismax
   • "An advanced multi-field query parser based on the dismax parser"
       - Handles "lucene" syntax as well as dismax features
   • Fields available to user may be limited (uf)
       - including negations and dynamic fields, e.g. uf=* -cost -timestamp
   • Shingles query into 2 and 3 term phrases
       - Improves quality of results when query contains terms across multiple fields
       - pf2/pf3 and ps2/ps3
       - removes stop words from shingled phrase queries
   • multiplicative "boost" functions
   • Additional features
       - Query comprised entirely of "stopwords" optionally allowed
           • if indexed, but query analyzer is set to remove them
       - Allow "lowercaseOperators" by default; or/OR, and/AND



                                                                                        12
term query parser
    • FieldType aware, no analysis
      - converts to internal representation automatically
    • "raw" query parser is similar
      - though raw parser is not field type aware; no
         internal representation conversion
    • Best practice for filtering on single facet
       value
      - fq={!term f=facet_field}crazy:value :)
         • no query string escaping needed; but of course still
            need URL encoding when appropriate




                                                                  13
prefix query parser
    • No field type awareness
    • {!prefix f=field_name}prefixValue
      - Similar to Lucene query parser
         field_name:prefixValue*
      - Solr's "lucene" query parser has multiterm
         analysis capability, but the prefix query parser
         does not analyze




                                                            14
boost query parser
    • Multiplicative to wrapped query score
      - Internally used by edismax "boost"
    • {!boost b=recip(ms(NOW,mydatefield),
       3.16e-11,1,1)}foo




                                              15
field query parser
    • Same as handling of field:"Some Text" clause by Solr's
        "lucene" query parser
    • FieldType aware
       - TermQuery generated, unless field type has special handling
    • TextField
       -   PhraseQuery: if multiple tokens in different positions
       -   MultiPhraseQuery: if multiple tokens share some positions
       -   BooleanQuery: if multiple terms all in same position
       -   TermQuery: if only a single token

    • Other types that handle field queries specially:
       - currency, spatial types (point, latlon, etc)
       - {!field f=location}49.25,8.883333

                                                                       16
surround query parser
   • Creates Lucene SpanQuery's for fine-grained proximity
       matching, including use of wildcards
   • Uses infix and prefix notation
      - infix: AND/OR/NOT/nW/nN/()
      - prefix: AND/OR/nW/nN
      - Supports Lucene query parser basics
          • field:value, boost^5, wild?c*rd, prefix*
      - Proximity operators:
          • N: ordered
          • W: unordered

   • No analysis of clauses
      - requires user or search client to lowercase, normalize, etc
   • Example:
      - q={!surround}Apache* 4w Portland

                                                                      17
join query parser
    • Pseudo-join
       - Field values from inner result set used to map to another field to select final
            result set
       - No information from inner result set carries to final result set, such as
            scores or field values (it's not SQL!)

    • Can join from another local Solr core
       - Allows for different types of entities to be indexed in separate indexes
            altogether, modeled into clean schemas
       - Separate cores can scale independently, especially with commit and
            warming issues

    • Syntax:
       - {!join from=... to=... [fromIndex=core_name]}query
    • For more information:
       - Yonik's Lucene Revolution 2011 presentation: http://vimeo.com/25015101
       - http://wiki.apache.org/solr/Join


                                                                                           18
spatial query parsers
    • Operates on geohash, latlon, and point types
    • geofilt
       - Exact distance filtering
       - fq={!geofilt sfield=location pt=10.312,-20.556 d=3.5}
    • bbox
       - Alternatively use a range query:
            • fq=location:[45,-94 TO 46,-93]
    • Can use in conjunction with geodist() function
       - Sorting:
            • sort=geodist() asc
       -   Returning distance:
            • fl=_dist_:geodist()


                                                                 19
frange: function range
    • Match a field term range, textual or numeric
    • Example:
      - fq={!frange l=0 u=2.2}
         sum(user_ranking,editor_ranking)




                                                     20
switch query parser
    • acts like a "switch/case" statement
    • Example:
      - fq={!switch
            case.all='*:*'
            case.yes='inStock:true'
            case.no='inStock:false'
            v=$in_stock}
      - &in_stock=yes
    • Solr 4.2+



                                            21
PostFilter
    • Query's implementing PostFilter interface consulted after
        query and all other filters have narrowed documents for
        consideration
    • Queries supporting PostFilter
       - frange, geofilt, bbox
    • Enabled by setting cache=false and cost >= 100
       - Example:
           • fq={!frange l=5 cache=false cost=200}div(log(popularity),sqrt(geodist()))
    • More info:
       - Advanced filter caching
           • http://searchhub.org/2012/02/10/advanced-filter-caching-in-solr/
       - Custom security filtering
           • http://searchhub.org/2012/02/22/custom-security-filtering-in-solr/


                                                                                         22
Phonetic, Stem, Synonym
   • Users tend to expect loose matching
      - but with "more exact" matches ranked higher
   • Various mechanisms for loosening matching:
      - Phonetic sounds-like: cat/kat, similar/similer
      - Stemming: search/searches/searched/searching
      - Synonyms: cat/feline, dog/canine
   • Distinguish ranking between exact and looser matching:
      - copyField original to a new (unstored, yet indexed) field with
           desired looser matching analysis
      - query across original field and looser field, with higher boosting
           for original field
          • /select?q=ApatchyCon&defType=dismax&qf=name^5 name_phonetic




                                                                             23
Suggest things, not strings
    • Model It As You Need It
       - Leverage Lucene's Document/Field/Query/score & sort &
           highlight

    • Example 1: Selling automobile parts
       - Exact year/make/model is needed to pick the right parts
       - Suggest a vehicle as user types
          • from the main parts index: tricky, requires lots of special fields and analysis
               tricks and even then you're suggesting fields from "parts"
          • Another (better?) approach: model vehicles as a separate core, "search"
               when suggesting, return documents, not field terms

    • Example 2: Technical Conferences
       - /select?q=Con&wt=csv&fl=name
          • Lucene EuroCon
          • ApacheCon



                                                                                              24
Query parsing and relevancy
   • The query is the formula that determines
      each document's score
   • Tuning is about what your application needs
     - Build tests using your corpus and real-world
        queries and ranking expectations
     - Re-run tests frequently/continuously as query
        parameters are tweaked
   • Tooling, currently, is mostly in-house custom
     - but that's changing, stay tuned!



                                                       25
Development/troubleshooting
   • Analysis
      - /analysis/field
          • ?analysis.fieldname=name
          • &analysis.fieldvalue=NA ApacheCon 2013
          • &q=apachecon
          • &analysis.showmatch=true
      - Also /analysis/document
      - admin UI analysis tool
   • Query Parsing
      - &debug=query
   • Relevancy
      - &debug=results
          • shows scoring explanations


                                                     26
Future of Solr query parsing
    • JSON query parser
    • XML query parser
    • PayloadTermQuery parser




                                27
JSON query parser
   • https://issues.apache.org/jira/browse/
      SOLR-4351
   • Current patch enables these:
     - {'term':{'id':'13'}}
     - {'field':{'text':'ApacheCon'}}
     - {'frange':{'v':'mul(rating,2)', 'l':20,'u':24}}}
     - {'join':{'from':'book_id', 'to':'id', 'v':{'term':
         {'text':'search'}}}}




                                                            28
XML query parser
   • Will allow a rich query "tree"
   • Parameters will fill in variables in a server-
      side XSLT query tree definition, or can
      provide full query tree
   • Useful for "advanced" query, multi-valued,
      input
   • https://issues.apache.org/jira/browse/
      SOLR-839




                                                      29
Payload term query parser
   • Solr supports indexing payload data on
      terms using DelimitedPayloadTokenFilter,
      but currently no support for querying with
      payloads
   • Requires custom Similarity implementation
      to provide score factor for payload data
   • Allows index-time weighting of terms
     - e.g. <b>bold words</b> weighted higher
   • https://issues.apache.org/jira/browse/
      SOLR-1485


                                                   30
BlockJoinQuery
   • https://issues.apache.org/jira/browse/
      SOLR-3076
   • Lucene provides a way to index a
      hierarchical "block" of documents and
      query it using ToParentBlockJoinQuery
      and ToChildBlockJoinQuery
     - Indexing a block is not yet supported by Solr
   • Example use case: What books greater than
      100 pages have paragraphs containing
      "information retrieval"?


                                                       31
32

More Related Content

What's hot

Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to ElasticsearchRuslan Zavacky
 
Sentiment Analysis Using Solr
Sentiment Analysis Using SolrSentiment Analysis Using Solr
Sentiment Analysis Using SolrPradeep Pujari
 
Haystack 2019 - Custom Solr Query Parser Design Option, and Pros & Cons - Ber...
Haystack 2019 - Custom Solr Query Parser Design Option, and Pros & Cons - Ber...Haystack 2019 - Custom Solr Query Parser Design Option, and Pros & Cons - Ber...
Haystack 2019 - Custom Solr Query Parser Design Option, and Pros & Cons - Ber...OpenSource Connections
 
Neural Search Comes to Apache Solr
Neural Search Comes to Apache SolrNeural Search Comes to Apache Solr
Neural Search Comes to Apache SolrSease
 
Scaling Through Partitioning and Shard Splitting in Solr 4
Scaling Through Partitioning and Shard Splitting in Solr 4Scaling Through Partitioning and Shard Splitting in Solr 4
Scaling Through Partitioning and Shard Splitting in Solr 4thelabdude
 
How to Build a Semantic Search System
How to Build a Semantic Search SystemHow to Build a Semantic Search System
How to Build a Semantic Search SystemTrey Grainger
 
Workshop: Learning Elasticsearch
Workshop: Learning ElasticsearchWorkshop: Learning Elasticsearch
Workshop: Learning ElasticsearchAnurag Patel
 
How the Lucene More Like This Works
How the Lucene More Like This WorksHow the Lucene More Like This Works
How the Lucene More Like This WorksSease
 
Dense Retrieval with Apache Solr Neural Search.pdf
Dense Retrieval with Apache Solr Neural Search.pdfDense Retrieval with Apache Solr Neural Search.pdf
Dense Retrieval with Apache Solr Neural Search.pdfSease
 
How to Extend Apache Spark with Customized Optimizations
How to Extend Apache Spark with Customized OptimizationsHow to Extend Apache Spark with Customized Optimizations
How to Extend Apache Spark with Customized OptimizationsDatabricks
 
Informational Referential Integrity Constraints Support in Apache Spark with ...
Informational Referential Integrity Constraints Support in Apache Spark with ...Informational Referential Integrity Constraints Support in Apache Spark with ...
Informational Referential Integrity Constraints Support in Apache Spark with ...Databricks
 
Introduction to Apache solr
Introduction to Apache solrIntroduction to Apache solr
Introduction to Apache solrKnoldus Inc.
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersCarlos Sierra
 
Staying Ahead of the Curve with Spring and Cassandra 4 (SpringOne 2020)
Staying Ahead of the Curve with Spring and Cassandra 4 (SpringOne 2020)Staying Ahead of the Curve with Spring and Cassandra 4 (SpringOne 2020)
Staying Ahead of the Curve with Spring and Cassandra 4 (SpringOne 2020)Alexandre Dutra
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMike Friedman
 
Real Time search using Spark and Elasticsearch
Real Time search using Spark and ElasticsearchReal Time search using Spark and Elasticsearch
Real Time search using Spark and ElasticsearchSigmoid
 

What's hot (20)

Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
Sentiment Analysis Using Solr
Sentiment Analysis Using SolrSentiment Analysis Using Solr
Sentiment Analysis Using Solr
 
Haystack 2019 - Custom Solr Query Parser Design Option, and Pros & Cons - Ber...
Haystack 2019 - Custom Solr Query Parser Design Option, and Pros & Cons - Ber...Haystack 2019 - Custom Solr Query Parser Design Option, and Pros & Cons - Ber...
Haystack 2019 - Custom Solr Query Parser Design Option, and Pros & Cons - Ber...
 
Neural Search Comes to Apache Solr
Neural Search Comes to Apache SolrNeural Search Comes to Apache Solr
Neural Search Comes to Apache Solr
 
Scaling Through Partitioning and Shard Splitting in Solr 4
Scaling Through Partitioning and Shard Splitting in Solr 4Scaling Through Partitioning and Shard Splitting in Solr 4
Scaling Through Partitioning and Shard Splitting in Solr 4
 
How to Build a Semantic Search System
How to Build a Semantic Search SystemHow to Build a Semantic Search System
How to Build a Semantic Search System
 
Workshop: Learning Elasticsearch
Workshop: Learning ElasticsearchWorkshop: Learning Elasticsearch
Workshop: Learning Elasticsearch
 
How the Lucene More Like This Works
How the Lucene More Like This WorksHow the Lucene More Like This Works
How the Lucene More Like This Works
 
Dense Retrieval with Apache Solr Neural Search.pdf
Dense Retrieval with Apache Solr Neural Search.pdfDense Retrieval with Apache Solr Neural Search.pdf
Dense Retrieval with Apache Solr Neural Search.pdf
 
How to Extend Apache Spark with Customized Optimizations
How to Extend Apache Spark with Customized OptimizationsHow to Extend Apache Spark with Customized Optimizations
How to Extend Apache Spark with Customized Optimizations
 
JSON-LD and MongoDB
JSON-LD and MongoDBJSON-LD and MongoDB
JSON-LD and MongoDB
 
Apache Solr
Apache SolrApache Solr
Apache Solr
 
Informational Referential Integrity Constraints Support in Apache Spark with ...
Informational Referential Integrity Constraints Support in Apache Spark with ...Informational Referential Integrity Constraints Support in Apache Spark with ...
Informational Referential Integrity Constraints Support in Apache Spark with ...
 
Apache Solr
Apache SolrApache Solr
Apache Solr
 
Introduction to Apache solr
Introduction to Apache solrIntroduction to Apache solr
Introduction to Apache solr
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginners
 
Staying Ahead of the Curve with Spring and Cassandra 4 (SpringOne 2020)
Staying Ahead of the Curve with Spring and Cassandra 4 (SpringOne 2020)Staying Ahead of the Curve with Spring and Cassandra 4 (SpringOne 2020)
Staying Ahead of the Curve with Spring and Cassandra 4 (SpringOne 2020)
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 
SQL Tuning 101
SQL Tuning 101SQL Tuning 101
SQL Tuning 101
 
Real Time search using Spark and Elasticsearch
Real Time search using Spark and ElasticsearchReal Time search using Spark and Elasticsearch
Real Time search using Spark and Elasticsearch
 

Similar to Solr Query Parsing

Query Parsing - Tips and Tricks
Query Parsing - Tips and TricksQuery Parsing - Tips and Tricks
Query Parsing - Tips and TricksErik Hatcher
 
Solr Black Belt Pre-conference
Solr Black Belt Pre-conferenceSolr Black Belt Pre-conference
Solr Black Belt Pre-conferenceErik Hatcher
 
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)Kai Chan
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 
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)
 
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
 
Apache Solr - Enterprise search platform
Apache Solr - Enterprise search platformApache Solr - Enterprise search platform
Apache Solr - Enterprise search platformTommaso Teofili
 
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
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrErik Hatcher
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 
nGram full text search (by 이성욱)
nGram full text search (by 이성욱)nGram full text search (by 이성욱)
nGram full text search (by 이성욱)I Goo Lee.
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrErik Hatcher
 
Find it, possibly also near you!
Find it, possibly also near you!Find it, possibly also near you!
Find it, possibly also near you!Paul Borgermans
 
Intro to Elasticsearch
Intro to ElasticsearchIntro to Elasticsearch
Intro to ElasticsearchClifford James
 
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
 

Similar to Solr Query Parsing (20)

Query Parsing - Tips and Tricks
Query Parsing - Tips and TricksQuery Parsing - Tips and Tricks
Query Parsing - Tips and Tricks
 
Solr Black Belt Pre-conference
Solr Black Belt Pre-conferenceSolr Black Belt Pre-conference
Solr Black Belt Pre-conference
 
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Solr5
Solr5Solr5
Solr5
 
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
 
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
 
Apache Solr - Enterprise search platform
Apache Solr - Enterprise search platformApache Solr - Enterprise search platform
Apache Solr - Enterprise search platform
 
What's new in solr june 2014
What's new in solr june 2014What's new in solr june 2014
What's new in solr june 2014
 
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)
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Apache solr
Apache solrApache solr
Apache solr
 
Apache Solr for begginers
Apache Solr for begginersApache Solr for begginers
Apache Solr for begginers
 
nGram full text search (by 이성욱)
nGram full text search (by 이성욱)nGram full text search (by 이성욱)
nGram full text search (by 이성욱)
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
Find it, possibly also near you!
Find it, possibly also near you!Find it, possibly also near you!
Find it, possibly also near you!
 
Intro to Elasticsearch
Intro to ElasticsearchIntro to Elasticsearch
Intro to Elasticsearch
 
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"
 

More from Erik Hatcher

Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Erik Hatcher
 
Solr Indexing and Analysis Tricks
Solr Indexing and Analysis TricksSolr Indexing and Analysis Tricks
Solr Indexing and Analysis TricksErik 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
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrErik Hatcher
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with SolrErik Hatcher
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development TutorialErik Hatcher
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes WorkshopErik 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
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with SolrErik Hatcher
 
Solr Powered Lucene
Solr Powered LuceneSolr Powered Lucene
Solr Powered LuceneErik 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
 

More from Erik Hatcher (20)

Ted Talk
Ted TalkTed Talk
Ted Talk
 
Solr Payloads
Solr PayloadsSolr Payloads
Solr Payloads
 
it's just search
it's just searchit's just search
it's just search
 
Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)
 
Solr Indexing and Analysis Tricks
Solr Indexing and Analysis TricksSolr Indexing and Analysis Tricks
Solr Indexing and Analysis Tricks
 
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
 
Solr 4
Solr 4Solr 4
Solr 4
 
Solr Recipes
Solr RecipesSolr Recipes
Solr Recipes
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Solr Flair
Solr FlairSolr Flair
Solr Flair
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development Tutorial
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes Workshop
 
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
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Solr Powered Lucene
Solr Powered LuceneSolr Powered Lucene
Solr Powered Lucene
 
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,...
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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...DianaGray10
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 

Solr Query Parsing

  • 1. Query Parsing Presented by Erik Hatcher 27 February 2013 1
  • 2. Description Interpreting what the user meant and what they ideally would like to find is tricky business. This talk will cover useful tips and tricks to better leverage and extend Solr's analysis and query parsing capabilities to more richly parse and interpret user queries. 2
  • 3. Abstract In this talk, Solr's built-in query parsers will be detailed included when and how to use them. Solr has nested query parsing capability, allowing for multiple query parsers to be used to generate a single query. The nested query parsing feature will be described and demonstrated. In many domains, e-commerce in particular, parsing queries often means interpreting which entities (e.g. products, categories, vehicles) the user likely means; this talk will conclude with techniques to achieve richer query interpretation. 3
  • 6. What’s new in 4.x? • Surround query parser • _query_:”{!...}” ugliness now unnecessary - just use nested {!...} expressions • Coming to 4.2: "switch" query parser 6
  • 7. "lucene"-syntax query parser • FieldType awareness - range queries, numerics - allows date math - reverses wildcard terms, if indexing used ReverseWildcardFilter • Magic fields - _val_: function query injection - _query_: nested query, to use a different query parser • Multi-term analysis (type="multiterm") - Analyzes prefix, wildcard, regex expressions to normalize diacritics, lowercase, etc - If not explicitly defined, all MultiTermAwareComponent's from query analyzer are used, or KeywordTokenizer for effectively no analysis 7
  • 8. dismax • Simple constrained syntax - "supports phrases" +requiredTerms -prohibitedTerms loose terms • Spreads terms across specified query fields (qf) and entire query string across phrase fields (pf) - with field-specific boosting - and explicit and implicit phrase slop - scores each document with the maximum score for that document as produced by any subquery; primary score associated with the highest boost, not the sum of the field scores (as BooleanQuery would give) • Minimum match (mm) allows query fields gradient between AND and OR - some number of terms must match, but not all necessarily, and can vary depending on number of actual query terms • Additive boost queries (bq) and boost functions (bf) • Debug output includes parsed boost and function queries 8
  • 9. Specifying the query parser • defType=parser_name - defines main query parser • {!parser_name local=param...}expression - Can specify parser per query expression • These are equivalent: - q=ApacheCon NA 2013&defType=dismax&mm=2&qf=name - q={!dismax qf=name mm=2}ApacheCon NA 2013 - q={!dismax qf=name mm=2 v='ApacheCon NA 2013'} 9
  • 10. Local Parameter Substitution /document?id=13 10
  • 11. Nested Query Parsing • Leverages the "lucene" query parser's _query_/{!...} trick • Example: - q={!dismax qf='title^2 body' v=$user_query} AND {!dismax qf='keywords^5 description^2' v=$topic} - &user_query=ApacheCon NA 2013 - &topic=events • Setting the complex nested q parameter in a request handler can make the client request lean and clean - And even qf and other parameters can be substituted: • {!dismax qf=$title_qf pf=$title_pf v=$title_query} • &title_qf=title^5 subtitle^2... • Real world example, Stanford University Libraries: - http://searchworks.stanford.edu/advanced - Insanely complex sets of nested dismax's and qf/pf settings 11
  • 12. edismax: extended dismax • "An advanced multi-field query parser based on the dismax parser" - Handles "lucene" syntax as well as dismax features • Fields available to user may be limited (uf) - including negations and dynamic fields, e.g. uf=* -cost -timestamp • Shingles query into 2 and 3 term phrases - Improves quality of results when query contains terms across multiple fields - pf2/pf3 and ps2/ps3 - removes stop words from shingled phrase queries • multiplicative "boost" functions • Additional features - Query comprised entirely of "stopwords" optionally allowed • if indexed, but query analyzer is set to remove them - Allow "lowercaseOperators" by default; or/OR, and/AND 12
  • 13. term query parser • FieldType aware, no analysis - converts to internal representation automatically • "raw" query parser is similar - though raw parser is not field type aware; no internal representation conversion • Best practice for filtering on single facet value - fq={!term f=facet_field}crazy:value :) • no query string escaping needed; but of course still need URL encoding when appropriate 13
  • 14. prefix query parser • No field type awareness • {!prefix f=field_name}prefixValue - Similar to Lucene query parser field_name:prefixValue* - Solr's "lucene" query parser has multiterm analysis capability, but the prefix query parser does not analyze 14
  • 15. boost query parser • Multiplicative to wrapped query score - Internally used by edismax "boost" • {!boost b=recip(ms(NOW,mydatefield), 3.16e-11,1,1)}foo 15
  • 16. field query parser • Same as handling of field:"Some Text" clause by Solr's "lucene" query parser • FieldType aware - TermQuery generated, unless field type has special handling • TextField - PhraseQuery: if multiple tokens in different positions - MultiPhraseQuery: if multiple tokens share some positions - BooleanQuery: if multiple terms all in same position - TermQuery: if only a single token • Other types that handle field queries specially: - currency, spatial types (point, latlon, etc) - {!field f=location}49.25,8.883333 16
  • 17. surround query parser • Creates Lucene SpanQuery's for fine-grained proximity matching, including use of wildcards • Uses infix and prefix notation - infix: AND/OR/NOT/nW/nN/() - prefix: AND/OR/nW/nN - Supports Lucene query parser basics • field:value, boost^5, wild?c*rd, prefix* - Proximity operators: • N: ordered • W: unordered • No analysis of clauses - requires user or search client to lowercase, normalize, etc • Example: - q={!surround}Apache* 4w Portland 17
  • 18. join query parser • Pseudo-join - Field values from inner result set used to map to another field to select final result set - No information from inner result set carries to final result set, such as scores or field values (it's not SQL!) • Can join from another local Solr core - Allows for different types of entities to be indexed in separate indexes altogether, modeled into clean schemas - Separate cores can scale independently, especially with commit and warming issues • Syntax: - {!join from=... to=... [fromIndex=core_name]}query • For more information: - Yonik's Lucene Revolution 2011 presentation: http://vimeo.com/25015101 - http://wiki.apache.org/solr/Join 18
  • 19. spatial query parsers • Operates on geohash, latlon, and point types • geofilt - Exact distance filtering - fq={!geofilt sfield=location pt=10.312,-20.556 d=3.5} • bbox - Alternatively use a range query: • fq=location:[45,-94 TO 46,-93] • Can use in conjunction with geodist() function - Sorting: • sort=geodist() asc - Returning distance: • fl=_dist_:geodist() 19
  • 20. frange: function range • Match a field term range, textual or numeric • Example: - fq={!frange l=0 u=2.2} sum(user_ranking,editor_ranking) 20
  • 21. switch query parser • acts like a "switch/case" statement • Example: - fq={!switch case.all='*:*' case.yes='inStock:true' case.no='inStock:false' v=$in_stock} - &in_stock=yes • Solr 4.2+ 21
  • 22. PostFilter • Query's implementing PostFilter interface consulted after query and all other filters have narrowed documents for consideration • Queries supporting PostFilter - frange, geofilt, bbox • Enabled by setting cache=false and cost >= 100 - Example: • fq={!frange l=5 cache=false cost=200}div(log(popularity),sqrt(geodist())) • More info: - Advanced filter caching • http://searchhub.org/2012/02/10/advanced-filter-caching-in-solr/ - Custom security filtering • http://searchhub.org/2012/02/22/custom-security-filtering-in-solr/ 22
  • 23. Phonetic, Stem, Synonym • Users tend to expect loose matching - but with "more exact" matches ranked higher • Various mechanisms for loosening matching: - Phonetic sounds-like: cat/kat, similar/similer - Stemming: search/searches/searched/searching - Synonyms: cat/feline, dog/canine • Distinguish ranking between exact and looser matching: - copyField original to a new (unstored, yet indexed) field with desired looser matching analysis - query across original field and looser field, with higher boosting for original field • /select?q=ApatchyCon&defType=dismax&qf=name^5 name_phonetic 23
  • 24. Suggest things, not strings • Model It As You Need It - Leverage Lucene's Document/Field/Query/score & sort & highlight • Example 1: Selling automobile parts - Exact year/make/model is needed to pick the right parts - Suggest a vehicle as user types • from the main parts index: tricky, requires lots of special fields and analysis tricks and even then you're suggesting fields from "parts" • Another (better?) approach: model vehicles as a separate core, "search" when suggesting, return documents, not field terms • Example 2: Technical Conferences - /select?q=Con&wt=csv&fl=name • Lucene EuroCon • ApacheCon 24
  • 25. Query parsing and relevancy • The query is the formula that determines each document's score • Tuning is about what your application needs - Build tests using your corpus and real-world queries and ranking expectations - Re-run tests frequently/continuously as query parameters are tweaked • Tooling, currently, is mostly in-house custom - but that's changing, stay tuned! 25
  • 26. Development/troubleshooting • Analysis - /analysis/field • ?analysis.fieldname=name • &analysis.fieldvalue=NA ApacheCon 2013 • &q=apachecon • &analysis.showmatch=true - Also /analysis/document - admin UI analysis tool • Query Parsing - &debug=query • Relevancy - &debug=results • shows scoring explanations 26
  • 27. Future of Solr query parsing • JSON query parser • XML query parser • PayloadTermQuery parser 27
  • 28. JSON query parser • https://issues.apache.org/jira/browse/ SOLR-4351 • Current patch enables these: - {'term':{'id':'13'}} - {'field':{'text':'ApacheCon'}} - {'frange':{'v':'mul(rating,2)', 'l':20,'u':24}}} - {'join':{'from':'book_id', 'to':'id', 'v':{'term': {'text':'search'}}}} 28
  • 29. XML query parser • Will allow a rich query "tree" • Parameters will fill in variables in a server- side XSLT query tree definition, or can provide full query tree • Useful for "advanced" query, multi-valued, input • https://issues.apache.org/jira/browse/ SOLR-839 29
  • 30. Payload term query parser • Solr supports indexing payload data on terms using DelimitedPayloadTokenFilter, but currently no support for querying with payloads • Requires custom Similarity implementation to provide score factor for payload data • Allows index-time weighting of terms - e.g. <b>bold words</b> weighted higher • https://issues.apache.org/jira/browse/ SOLR-1485 30
  • 31. BlockJoinQuery • https://issues.apache.org/jira/browse/ SOLR-3076 • Lucene provides a way to index a hierarchical "block" of documents and query it using ToParentBlockJoinQuery and ToChildBlockJoinQuery - Indexing a block is not yet supported by Solr • Example use case: What books greater than 100 pages have paragraphs containing "information retrieval"? 31
  • 32. 32