2. Agenda
● Facets
○ Introduction
○ Multi Select Faceting
○ Dynamic Range Faceting
● Reordering Documents
○ Default Scoring Formula
○ Function Queries To Reorder Documents
○ Query Elevation Component
● Query Elevation Component
3. Faceted Search
● Also known as guided navigation
● Essentially it's a group by on a field
● Values returned are calculated on the
documents from the search results
8. Implementing Dynamic
Price Range
Dynamic range faceting means that we can
group results into buckets of sizes that you
want instead of a fixed bucket range and gap
● &q = *
● &facet = true
● &facet.field = Brand
● &facet.query = Price:[0 TO 5000]
● &facet.query = Price:[5001 TO 8000]
● &facet.query = Price:[8001 TO 15000]
● &facet.query = Price:[15001 TO *]
9. Multi-Select Faceting
Example
Multi-Select Faceting gives the ability
to display facet counts despite the
result set being filtered
Multi-Select
Faceting
gives the
ability to
display facet
counts of
other brands
despite the
result set
being filtered
on brand HTC
10. Multi-Select Faceting
Implementation
● tag: Tags a filter with an arbitrary name
● ex: Excludes a tag filter from being applied on a
facet field/query.
● key: Tags a facet field an arbitrary name (instead
of field name).
To Implement In Solr:
● q = android phones
● facet = true
● fq = {!tag=brand_tag}brand:"HTC"
● facet.field = {!ex=brand_tag}brand
11. Result Options
● Sort by relevancy
○ Default TF-IDF Scores
○ Boost cheaper products
○ Boost newer products
○ Boost high average user clicks and user ratings
○ Boost high selling products
● Fix top results on a per query basis
12. Function Queries
● Apply functions to a field to alter the score of
a document
● It iterates over all documents serially
applying the function
● Can be multiplied into the score by using the
boost param in the eDismax request handler
13. TF-IDF Scoring
● tf - Number of times a term occurs in a
document
● idf - Measure of how unique a term is
● lengthNorm - Penalizes long docs with few
term occurrences on index time.
● Doesn't work well for small documents
14. Boost cheaper products
● Blindly sort the result
○ &sort = price asc
● Give preference to cheaper products
○ Boost value of 2 for the cheapest product
○ Boost value of 1 for the most expensive product
○ &bf = add(div(sub(price, min), sub(max, min)), 1)
■ Use the StatsComponent to get min,max
■ Use the min, max function queries
■ Know your data and use realistic values
15. Boosting Newer Products
● Blindly sort the result
○ &sort = release_date desc
● Give preference to Newer Products
○ recip(ms(NOW/DAY,pub_date),3.16e-11,1,1)
○ Where recip(m, x, a, b) = a / (mx + b)
○ Picking a=2, b =1, m = 3.16e-11
○ Gives a boost =2 for todays product
○ Gives a boost =1.3 for 1/2 year old product
○ Gives a boost =1 for 1 year old product and so on
16. Boost high margin
products
● You have a index field called margin
● Again you can always sort on this field
● Or you can give it subtle boosts
○ Let's say you want to boost product which have a
margin more than 50%
○ map(margin_field, 50, 100, 2)
● You can use a high selling, user rating
approach instead too
17. Query Elevation
Component
● Fix particular documents for certain queries
● No scoring is taken into consideration for
these queries
<elevate>
<query text="android phones">
<doc id="nexus 4" />
<doc id="pick a phone :)" exclude="true"/>
</query>
</elevate>
18. Conclusion
● Facets have a lot of other use cases -
Analytics. Ex. Range facets to populate
histograms
● Always keep tweaking parameters and
measuring effectiveness of your function
queries.
● Use Query Elevation Component for your
top queries