Faceted Search And Result Reordering

19
Faceted Search And Result Reordering Varun Thacker, Unbxd Inc.

description

A talk on Faceted Search And Result Reordering

Transcript of Faceted Search And Result Reordering

Page 1: Faceted Search And Result Reordering

Faceted Search And Result Reordering

Varun Thacker, Unbxd Inc.

Page 2: Faceted Search And Result Reordering

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

Page 3: Faceted Search And Result Reordering

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

Page 4: Faceted Search And Result Reordering

Brand Facet

Price Facet

Counts

Total Count

Page 5: Faceted Search And Result Reordering

How can we this Implement In Solr

● q = android phones● facet = true● facet.field = brand● facet.range = price● facet.range.start=0● facet.range.end=1000● facet.range.gap=100

● To Filter Results: &fq=brand:"HTC"

Page 6: Faceted Search And Result Reordering

Response in XML<lst name="facet_counts"> <lst name="facet_queries"/> <lst name="facet_fields"> <lst name="brand"> <int name="Samsung">293</int> <int name="HTC">100</int> ... </lst> </lst> <lst name="facet_dates"/> <lst name="facet_ranges"> <lst name="price"> <lst name="counts"> <int name="0">0</int> <int name="100">11</int> ... </lst> <int name="gap">100</int> <int name="start">0</int> <int name="end">500</int> </lst> </lst></lst>

Page 7: Faceted Search And Result Reordering

Dynamic Price Range

Total Count

Filters Applied

Filter + Dynamic Price Range

Page 8: Faceted Search And Result Reordering

Implementing Dynamic Price RangeDynamic 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 *]

Page 9: Faceted Search And Result Reordering

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

Page 10: Faceted Search And Result Reordering

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

Page 11: Faceted Search And Result Reordering

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

Page 12: Faceted Search And Result Reordering

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

Page 13: Faceted Search And Result Reordering

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

Page 14: Faceted Search And Result Reordering

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

Page 15: Faceted Search And Result Reordering

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

Page 16: Faceted Search And Result Reordering

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

Page 17: Faceted Search And Result Reordering

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>

Page 18: Faceted Search And Result Reordering

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

Page 19: Faceted Search And Result Reordering

Thank You

Questions?