New in Solr: Quickstart with Payloads in Solr

Support for payloads existed in Lucene since long, but good out of the box support for payloads in Solr has finally been introduced in version 6.6. Concept of payloads can be understood as a per-document map of terms to values (string or numeric). Payloads can be used to store metadata for documents. Payloads lend themselves very well to implement a per-document weighted attribute set that can be used for filtering/scoring of those documents.

In this example, let us create a collection using a tiny portion of the Open Product Data. For this e-commerce oriented usecase of payloads, we’ll add clickstream based payloads to help in achieving better relevance for user queries.

Start SolrCloud (7.0)

First of all, lets start Solr 7.1 in cloud mode.

Docker:

docker run -it -p 8983:8983 solr:7.1 /opt/solr/bin/solr -c -f

Without docker:

wget http://www-us.apache.org/dist/lucene/solr/7.1.0/solr-7.1.0.tgz
tar -xvf http://www-us.apache.org/dist/lucene/solr/7.1.0/solr-7.1.0.tgz
cd solr-7.1.0
bin/solr -c

Note: If you prefer using Postman, here is the postman collection that you can import.

Create a collection called “products”

curl -X POST "http://localhost:8983/api/collections" -d \
'{"create": {"name": "products", "numShards": 1}}'

Index a few documents into the collection

curl -X POST \
'http://localhost:8983/api/collections/products/update?commit=true' \
-H 'content-type: application/json' \
-d '[
{"id":"5000147030156", "title":"bargains4you | Bargains4You Iphone 4, Iphone 4S, Iphone s, Iphone 5, Iphone Signal & Wifi Boosters X 2"},
{"id":"0602956", "title":"Marware Membrane iPhone Case - iPhone - Smoke - Polypropylene"},
{"id":"0602956009542", "title":"Marware Membrane iPhone Case - iPhone - Smoke - Polypropylene"},
{"id":"087956904", "title":"Fosmon iPhone Case - iPhone - Purple - Silicone, Thermoplastic Polyurethane (TPU)"},
{"id":"0879569046442", "title":"Belkin BodyGuard Hue iPhone Case - iPhone - Yellow, Light Graphite"},
{"id":"0879569046459", "title":"Belkin Bodyguard Hue iPhone Case - iPhone - Garnet, Light Graphite"},
{"id":"0879569046541", "title":"Fosmon iPhone Case - iPhone - Blue - Silicone, Thermoplastic Polyurethane (TPU)"},
{"id":"0879569046565", "title":"Fosmon iPhone Case - iPhone - Orange - Silicone, Thermoplastic Polyurethane (TPU)"},
{"id":"0879569046572", "title":"Fosmon iPhone Case - iPhone - Green - Silicone, Thermoplastic Polyurethane (TPU)"},
{"id":"0879569046589", "title":"Fosmon iPhone Case - iPhone - Purple - Silicone, Thermoplastic Polyurethane (TPU)"},
{"id":"0885909229352", "title":"Iphone Mb048ll A Smartphone"},
{"id":"4713507011535", "title":"iMarkCase | Girrafe iPhone 4 / 4S Case - iPhone Designer Phone Case"},
{"id":"4713507", "title":"iMarkCase | Tiger iPhone 4 / 4S Covers - iPhone 4S Custom Phone Case"},
{"id":"8801105", "title":"iMarkCase | Spot iPhone 4 / 4S Covers - Design An iPhone Phone Case"},
{"id":"4713507019135", "title":"iMarkCase | Tiger iPhone 4 / 4S Covers - iPhone 4S Custom Phone Case"},
{"id":"8801105000535", "title":"iMarkCase | Spot iPhone 4 / 4S Covers - Design An iPhone Phone Case"},
{"id":"0758302", "title":"Ipad Ipod & Iphone Wall Charger"},
{"id":"0660543008323", "title":"Iphone 4 Impact Case Blue"},
{"id":"0758302638604", "title":"Ipad Ipod & Iphone Wall Charger"},
{"id":"0885909459865", "title":"Iphone 4s 32gb Black White"},
{"id":"0885909503865", "title":"Iphone 4 32gb In Black"},
{"id":"8801105000177", "title":"iMarkCase | Girl iPhone 4 / 4S Covers - Design Your Own iPhone 4S Phone Case"},
{"id":"0098689", "title":"Lucky Hard Case Feather Iphone 4"},
{"id":"0047532893908", "title":"Alarm Clock For Iphone Ipod Black"},
{"id":"0098689392233", "title":"Lucky Hard Case Feather Iphone 4"},
{"id":"0737795254515", "title":"Smartcord Live For Iphone 0010038-1"},
{"id":"0885909408269", "title":"Iphone 4s Never Locked White 32gb"},
{"id":"0885909526253", "title":"Iphone 4s Never Locked Black 32gb"},
{"id":"0898713010", "title":"iShieldz iPhone 3G/3GS Protective Film Cover"},
{"id":"69516970", "title":"Iphone Ipad Rc Controlled 3ch I-helicopter"},
{"id":"0610708506638", "title":"Genuine Swarovski Crystal Iphone Home Button Sticker"},
{"id":"0630403846334", "title":"Heli For Ipod Iphone And Ipad Orange"},
{"id":"0794809043336", "title":"Royce Leather iPhone 4 and 3GS Case"},
{"id":"0814523016130", "title":"Incipio BIGshow AV Cable for iPad/iPhone"},
{"id":"0847567046276", "title":"AC Wall Charger for Apple iPod/iPhone"},
{"id":"0873750005867", "title":"Magpul Field Case for iPhone 4/4S"},
{"id":"0898713010214", "title":"iShieldz iPhone 3G/3GS Protective Film Cover"},
{"id":"3560070180738", "title":"Iphone 5 Case Personalized Cherry ref 19"},
{"id":"6951697068030", "title":"Iphone Ipad Rc Controlled 3ch I-helicopter"},
{"id":"0738516", "title":"PureGear Charge-Sync Cable for iPhone & iPods - Black"},
{"id":"087136301", "title":"Rotating Speaker Dock For Iphone Model Dsc-midk101"},
{"id":"356007", "title":"Iphone 4/4S Case Personalized Heart ref 41"},
{"id":"0605388187406", "title":"foriphone | Protective TPU Case for iPhone 5 (White)"},
{"id":"0738516865454", "title":"PureGear Charge-Sync Cable for iPhone & iPods - Black"},
{"id":"0803218935009", "title":"BROWN CAMOUFLAGE for iPhone 4 Rubberized Hard Case"},
{"id":"0803218935016", "title":"BLUE CAMOUFLAGE for iPhone 4 Rubberized Hard Case"},
{"id":"0803218935023", "title":"GREEN CAMOUFLAGE for iPhone 4 Rubberized Hard Case"},
{"id":"0803218935047", "title":"PINK CAMOUFLAGE for iPhone 4 Rubberized Hard Case"},
{"id":"0817317010000", "title":"Uspin Music Dock For Apple Iphone And Ipod"},
{"id":"0871363016812", "title":"Rotating Speaker Dock For Iphone Model Dsc-midk101"},
{"id":"3245412846991", "title":"Iphone 4/4S Case Personalized Poker Ref 57"},
{"id":"3270190122210", "title":"Iphone 5 Case Personalized Audi Logo ref 26"},
{"id":"3560070764198", "title":"Iphone 4/4S Case Personalized Heart ref 41"},
{"id":"5740900804302", "title":"lighthouse design | Mario IPhone 4 Hard Case Cover"},
{"id":"0077979", "title":"Womens Clutch Wallet Tri-fold Iphone Cell Holder Quilted"},
{"id":"0803218", "title":"Blue Sinjimoru iPhone 4 iPod Charger Dock Stand +Data"},
{"id":"0803232", "title":"Hot Pink Data Cable For Apple iPhone iPod USB"},
{"id":"0885909", "title":"Iphone 4 Black 8gb Verizon 8 Gb Clean Esn"},
{"id":"376015407", "title":"PANTONE UNIVERSE iPHONE 4 COVER "BLUE 7462C""},
{"id":"5201671", "title":"ETHAHE | iPod Nano Touch iPhone SAV Video Cable White"},
{"id":"0077979074936", "title":"Womens Clutch Wallet Tri-fold Iphone Cell Holder Quilted"},
{"id":"0085896392439", "title":"Powerbolt Auto Adapter For Ipod Iphone And Usb Device"},
{"id":"0803218854621", "title":"For iPhone 3Gs USB input Travel Wall Charger Adapter"},
{"id":"0803218938963", "title":"Blue Sinjimoru iPhone 4 iPod Charger Dock Stand +Data"},
{"id":"0803232685676", "title":"Hot Pink Data Cable For Apple iPhone iPod USB"},
{"id":"0811398015350", "title":"Sports Images Texas Longhorns Cashmere Silicone iPhone 3G Case"},
{"id":"0847567046146", "title":"USB Data Sync Charger Cable For iPhone 3G Nano"},
{"id":"0871363014207", "title":"Ultra-portable Speaker System For Iphone Model Dsc-nipc400"},
{"id":"0879569021395", "title":"Dock Cradle Charger For iPhone 3G + USB Adapter Cable"},
{"id":"0879569046046", "title":"Case-mate Tough Case for Apple iPhone 4 (Yellow)"},
{"id":"0879569046053", "title":"Case-mate Tough Case for Apple iPhone 4 (Green)"},
{"id":"0879569046510", "title":"iLuv SPECTRUM Silicone Case for Apple iPhone 4 (yellow)"},
{"id":"0879569046527", "title":"iLuv SENTINEL Metallic Case for Apple iPhone 4 (Chrome)"},
{"id":"0883594031991", "title":"Wall Charger for iPod, iPhone, iPad and USB Devices"},
{"id":"0885909543267", "title":"Iphone 4 Black 8gb Verizon 8 Gb Clean Esn"},
{"id":"3245412207648", "title":"Iphone 4/4S Case Personalized Audi Logo ref 26"},
{"id":"3560070334971", "title":"Iphone 5 Case Personalized Audi A1 Sport ref 2"},
{"id":"3560070342761", "title":"Iphone 5 Case Personalized Paris Eiffel Tower ref 29"},
{"id":"3560070342877", "title":"Iphone 5 Case Personalized Apple Logo Multicolor Ref 30"},
{"id":"3760154072588", "title":"PANTONE UNIVERSE iPHONE 4 COVER "BLUE 7462C""},
{"id":"4895058310340", "title":"Hello Kitty | HELLO KITTY iPHONE 4 CHROME CASE GOLD"},
{"id":"4901313060599", "title":"lighthouse design | Mickey Mouse IPhone 4 Hard Case Cover"},
{"id":"5201671100241", "title":"ETHAHE | iPod Nano Touch iPhone SAV Video Cable White"},
{"id":"081731701", "title":"AT&T coolBlu Music Dock for Apple iPhone and iPod"},
{"id":"0856926003", "title":"Snow Lizard TEK BOOT Carrying Case for iPhone - Orange - Elastomer"},
{"id":"0047532899030", "title":"Dual Id38 Alarm Clock Fm Radio For Ipad Iphone Ipod"},
{"id":"0609585215726", "title":"Fidelio Docking Speaker Dock For Ipod Iphone Ipad Model Ds3510"},
{"id":"0609613649783", "title":"id America Cushi Dot Foam iPhone 4s Case - Disco Black"},
{"id":"0628586763807", "title":"I-helicopter Controlled Iphone Ipod Touch Ipad White 777-173w"},
{"id":"0660543005476", "title":"Defender Case Apl2-i4xxx-20-c4otr For Iphone 4 Black"},
{"id":"0803218934897", "title":"GREEN WATER COLOR FLOWERS for Apple iPhone 4 Hard Case"},
{"id":"0803218934903", "title":"PINK WATER COLOR FLOWERS for Apple iPhone 4 Hard Case"},
{"id":"0803218935030", "title":"HOT PINK for Apple iPhone 4 Rubberized Hard Case Cover"},
{"id":"0817317010017", "title":"AT&T coolBlu Music Dock for Apple iPhone and iPod"},
{"id":"0847551065245", "title":"USB Data Sync / Charging Cable for Apple iPhone 3G 4G"},
{"id":"0856926003072", "title":"Snow Lizard TEK BOOT Carrying Case for iPhone - Orange - Elastomer"},
{"id":"0859781002013", "title":"Looxcie | Looxcie LX1 Wearable Bluetooth Camcorder, iPhone and Android Compatible"},
{"id":"0879569046558", "title":"TPU Frame Cover Bumper Case for Apple iPhone 4 - Pink"},
{"id":"0885909528868", "title":"Iphone 4s 64gb Unlocked Gevey S Latest Model Overnight Available"},
{"id":"3270190186694", "title":"Iphone 4/4S Case Personalized Audi A5 Racing Ref 11"},
{"id":"3661163990507", "title":"disney | Disney Princess Peterpan Tinkerbell iphone 4 4s hard Case"},
{"id":"4710126035003", "title":"cath | Cath Kidston Big Red Flower Iphone 4/4s Case"},
{"id":"4902555135687", "title":"lighthouse design | Minnie mouse iphone 4 silicone case back cover"},
{"id":"0733108", "title":"iSkin Revo SE Case For Apple iPhone 4/4S (Blue/Black)"},
{"id":"9557062", "title":"Lighthouse design | Anime Naruto hard glossy case for iphone 4 4S"},
{"id":"0098689192017", "title":"Lucky Hardcase One-piece Snap-on Paisley For Iphone 4 4s"},
{"id":"0733108001531", "title":"iSkin Revo SE Case For Apple iPhone 4/4S (Blue/Black)"},
{"id":"0811398014841", "title":"Sports Images Penn State Nittany Lions Cashmere Silicone iPhone 3G Case"},
{"id":"0845793197564", "title":"SKQUE Premium MP3 Car Mount Holder for Apple iPhone 4 / 4G"},
{"id":"0847551061667", "title":"White USB Mini Car Charger + Charging/Data Cable for iPhone iPod"},
{"id":"0847551065221", "title":"USB Travel Wall AC Charger + Data Sync Charge Cable for iPhone"},
{"id":"0847551066167", "title":"White USB Data Sync / Charging Cable for Apple iPhone 3G 4G"},
{"id":"0859108016112", "title":"iPhone iPod iPad iTouch Cable Adapter for SVP Mini Projector PP003"},
{"id":"0885909499458", "title":"Official Iphone 4 8gb Black Gsm Factory Unlocked Smartphone Md128ll A"},
{"id":"0898334027417", "title":"Seidio Ultimate Screen Guard Screen Protection for iPhone 4 - Full Body"},
{"id":"0898334027530", "title":"Seidio Ultimate Screen Guard Screen Protection for iPhone 4 - Screen Only"},
{"id":"3760154072533", "title":"Case Scenario | Case Scenario - Pantone Universe iPhone 4 Case in Black"},
{"id":"9557062331128", "title":"Lighthouse design | Anime Naruto hard glossy case for iphone 4 4S"},
{"id":"0784090", "title":"Unlocked Iphone 3gs 32gb Black At&t T-mobile Any Gsm Carrier"},
{"id":"0852476003", "title":"Lark Silent Un-alarm Clock And Sleep Sensor For Iphone Ipod Ipad"},
{"id":"6221033", "title":"HR | For iPhone 4 (AT&T) - Hybird Cover Case - Black/White"},
{"id":"0088515910908", "title":"EVOPower USB Sync & Charge Cable+Mini USB Car Charger for iPhone 4G"},
{"id":"0784090092014", "title":"Unlocked Iphone 3gs 32gb Black At&t T-mobile Any Gsm Carrier"},
{"id":"0845793198431", "title":"SKQUE Premium MP3 Car Mount Holder for Apple iPhone 3G 8GB \\ 16GB"},
{"id":"0845793198448", "title":"SKQUE Premium MP3 Car Mount Holder for Apple iPhone 4GB \\ 8GB \\ 16GB"},
{"id":"0852476003005", "title":"Lark Silent Un-alarm Clock And Sleep Sensor For Iphone Ipod Ipad"},
{"id":"3560070332618", "title":"Iphone 4/4S Case Personalized Beach Landscape with a Cliff Ref 21"},
{"id":"3560070340057", "title":"Iphone 5 Case Personalized Apple Logo on a Grey Background Ref 35"},
{"id":"4005808867240", "title":"Kate Spade Eiffel Tower Hard Case Cover Shell for Apple Iphone 4"},
{"id":"4710126036161", "title":"Marc | MARC BY MARC JACOBS Big Hearted iPhone 4/4S Hard Case"},
{"id":"6221033173217", "title":"HR | For iPhone 4 (AT&T) - Hybird Cover Case - Black/White"},
{"id":"8806071164069", "title":"Iphone 3gs Lcd Display Touch Screen Digitizer Assembly Us Lcd-ip-155"},
{"id":"087956200", "title":"New Apple iPhone 3GS / 3G S, Apple iPhone 3G USB Adapter Car Charger + Wall AC USB Home Charger + USB Sync Charging Cable, White by SF Planet"},
{"id":"0879562006641", "title":"New Apple iPhone 3GS / 3G S, Apple iPhone 3G USB Adapter Car Charger + Wall AC USB Home Charger + USB Sync Charging Cable, White by SF Planet"},
{"id":"0898334027", "title":"Seidio Ultimate Screen Guard 2 Pack Screen Protection for iPhone 4 - Screen Only"},
{"id":"0074734061224", "title":"pacers | The Simpsons Apple iPhone 5 Protective Skin Decorative Sticker Decal, MAC1208-104"},
{"id":"0845793197878", "title":"SKQUE Premium MP3 Car Mount Holder for Apple iPhone 3G S 16GB \\ 32GB"},
{"id":"0847231073973", "title":"New 360 Degree Rotation Stainless Steel Stand Mount Holder For Apple iPhone 4G"},
{"id":"0848738001780", "title":"3 in1 USB Car Charger + AC Charger + Cable For iPhone 4G 3G 3GS"},
{"id":"0886610028517", "title":"Car Air Vent Phone Holder Mount For iPhone® 3 G 3GS 3rd"},
{"id":"0898334027424", "title":"Seidio Ultimate Screen Guard 2 Pack Screen Protection for iPhone 4 - Full Body"},
{"id":"0898334027547", "title":"Seidio Ultimate Screen Guard 2 Pack Screen Protection for iPhone 4 - Screen Only"},
{"id":"3560070340026", "title":"Iphone 4/4S Case Personalized Apple Logo on a Grey Background Ref 35"},
{"id":"0887777", "title":"Cuffu Md-708 Trusurround Computer Laptop Speakers Protable Speaker For Iphone Iphone Ipod Nano Classic Video Touch 1 & 2 Generation And Laptop Protable Computers With Our Lowest Shipping Rate"},
{"id":"0887777788894", "title":"Cuffu Md-708 Trusurround Computer Laptop Speakers Protable Speaker For Iphone Iphone Ipod Nano Classic Video Touch 1 & 2 Generation And Laptop Protable Computers With Our Lowest Shipping Rate"},
{"id":"087956502", "title":"Fosmon MATT Series Rubberized Hard Plastic Case Back Cover for Apple iPhone 5 - White"},
{"id":"087956903", "title":"Mini USB Car / Auto Charger Adapter - 5 V DC for Apple iPhone 5 - Black"},
{"id":"0898455467", "title":"For iPhone 5 Red White Combo Hard Rubber Case Cover + Screen Film + Stylus Pen"},
{"id":"489000816", "title":"more mickey | Disney Minnie Mickey'
\''s Girlfriend Silicone case cover for Apple Iphone 5 - Red"},
{"id":"4901050", "title":"lighthouse design | Hello Kitty Home Button Sticker for Apple Ipad/iphone //ipad2/ipod 4G"},
{"id":"6908512", "title":"iMarkCase | Disney Up russell Cases Covers for iPhone 4/4S Series IMCA-CP-0312"},
{"id":"7613033", "title":"Design-case | Iphone 4/4S Case Personalized Amazing Landscape with a Canyon Ref 22"},
{"id":"0045915817657", "title":"Ht-9500 Acutouch Massage Chair With Ht Connect For Ipod Iphone Ipad Color Black"},
{"id":"0074734088184", "title":"Melissa Design | iphone Bag Case with Wallet Made Pvc Material Purse Handbag Carrying Case"},
{"id":"0847181001705", "title":"Energizer Sync & Charge USB Cable 6 foot iPod iPad iPhone ENG-SYNCW USB 2.0"},
{"id":"0847551066341", "title":"USB Car + AC Wall Travel Charger + Data Sync / Charging Cable for iPhone 4 4G"},
{"id":"0879565023461", "title":"Fosmon MATT Series Rubberized Hard Plastic Case Back Cover for Apple iPhone 5 - White"},
{"id":"0879569038492", "title":"Mini USB Car / Auto Charger Adapter - 5 V DC for Apple iPhone 5 - Black"},
{"id":"0898455467666", "title":"For iPhone 5 Red White Combo Hard Rubber Case Cover + Screen Film + Stylus Pen"},
{"id":"4710626159513", "title":"Ymid Select | 3d Pattern Hard Back Case Skin Cover for Apple Iphone 4 4s"},
{"id":"4890008168934", "title":"more mickey | Disney Minnie Mickey'
\''s Girlfriend Silicone case cover for Apple Iphone 5 - Red"},
{"id":"4901050116504", "title":"lighthouse design | Hello Kitty Home Button Sticker for Apple Ipad/iphone //ipad2/ipod 4G"},
{"id":"6908512208645", "title":"iMarkCase | Disney Up russell Cases Covers for iPhone 4/4S Series IMCA-CP-0312"},
{"id":"6911988005205", "title":"Electronic | 2 in 1 Mirror LCD Screen Protector For iPhone 4 4th Gen HD"},
{"id":"7613033908910", "title":"Design-case | Iphone 4/4S Case Personalized Amazing Landscape with a Canyon Ref 22"},
{"id":"0898455384", "title":"Lot 20 Front+Back Screen Protector Shield Cover Film for New Apple iPhone 5 5G"},
{"id":"489703389", "title":"Luardi Lip4sygs02 Luardi 24k Gold-plated Metallic Skin For Iphone 4 4s-yellow Gold Paisley"},
{"id":"893486601", "title":"iMarkCase | iMarkCase MerryChristmas Series iphone 4 4s Case Cover Custom Case Colored Painting Polycarbonate ChristmasTree"},
{"id":"955507630", "title":"Sticker | HELLO KITTY mitten cellphone crystal sticker for iphone 4G cellphone mobile phone computer laptop"},
{"id":"0689466310962", "title":"Brick Wall USB Adapter Charger for Apple iPod & iPhone + 6ft LONG USB SYNC Cable Cord"},
{"id":"0847551066358", "title":"USB Car + AC Wall Travel Charger + Data Sync / Charging Cable for iPhone 4 4G - White"},
{"id":"0879569084482", "title":"Fosmon Premium Reusable Mirror LCD Screen Protector Film Guard for Apple iPhone 4S - 3 Pack"},
{"id":"0886610068827", "title":"WHITE RUBBER HARD COVER CASE+SCREEN FILM for iPhone® 4 4S 4G 4GS G"},
{"id":"0898455384932", "title":"Lot 20 Front+Back Screen Protector Shield Cover Film for New Apple iPhone 5 5G"},
{"id":"4713507019074", "title":"iMarkCase | Marvel Superhero Dead Pool Covers Cases for iPhone 4 4S Series iMCA-CP-0137"},
{"id":"4897033892391", "title":"Luardi Lip4sygs02 Luardi 24k Gold-plated Metallic Skin For Iphone 4 4s-yellow Gold Paisley"},
{"id":"7702018868643", "title":"Metalic slider Case | Original Lamborghini stainless steel Luxury iPhone 4/4S Case With Retail Packaging"},
{"id":"8410069001436", "title":"iMarkCase | Disney Sleeping Beauty Aurora Case Cover for iPhone 4 / 4S Series IMCA-PC-0395"},
{"id":"8934866012018", "title":"iMarkCase | iMarkCase MerryChristmas Series iphone 4 4s Case Cover Custom Case Colored Painting Polycarbonate ChristmasTree"},
{"id":"9555076300093", "title":"Sticker | HELLO KITTY mitten cellphone crystal sticker for iphone 4G cellphone mobile phone computer laptop"},
{"id":"0741360", "title":"SmackTom New Premium USB Adapter Wall Charger +Car Charger +Data Cable for iPod iPhone 3G 4S"},
{"id":"08456200", "title":"4 IN 1 COMBO CHARGER PACK FOR IPAD 1 & 2, IPHONE, IPOD & MOST USB POWERED DEVICE"},
{"id":"08475510", "title":"4 Piece Black Data Sync and Charging Kit for iPhone 3G 3GS w/ Handsfree Earphone Headset"},
{"id":"69340245", "title":"UMe | Cute 3d Elegant Luxury Handbag Silicone Cover Case with Chain for Iphone 4s - Deep Purple"},
{"id":"0088515819980", "title":"GTMax Full Front Clear LCD Screen Protector Film Shield Guard Cover for iPhone 3G/ 3G Sx5"},
{"id":"0088515837823", "title":"EVO Power iPod Car Charger+USB Date Cable-White for Apple iphone 4th/ipod touch 4th"},
{"id":"0741360980334", "title":"SmackTom New Premium USB Adapter Wall Charger +Car Charger +Data Cable for iPod iPhone 3G 4S"},
{"id":"0845620021499", "title":"4 IN 1 COMBO CHARGER PACK FOR IPAD 1 & 2, IPHONE, IPOD & MOST USB POWERED DEVICE"},
{"id":"0847551066860", "title":"4 Piece Black Data Sync and Charging Kit for iPhone 3G 3GS w/ Handsfree Earphone Headset"},
{"id":"6934024581150", "title":"UMe | Cute 3d Elegant Luxury Handbag Silicone Cover Case with Chain for Iphone 4s - Deep Purple"},
{"id":"4540121", "title":"lighthouse design | Stitch IPhone 4 Hard Case Cover in Retail Box + Free Screen Protector and Cleaning Cloth"},
{"id":"48950583", "title":"lighthouse design | Super Mario Bros Earphones Headphones for MP3 MP4 PC iPHONE + 3 Pairs of Spare Earbuds"},
{"id":"0610393751603", "title":"New RCA Composite AV Video to TV USB Charger Cable for iPad 2 3 iPhone 4 4S"},
{"id":"0637836475827", "title":"TRANS4M AC/DC Travel Charger for AT&T, Verizon Apple iPhone, iPod, Touch, Nano + Charge / Sync Cable"},
{"id":"0689466310948", "title":"SUPER LONG 10FT (TEN FEET!) USB Cable Charger SYNC for any iPod or iPhone (NEWBO BRAND) Black"},
{"id":"4540121863482", "title":"lighthouse design | Stitch IPhone 4 Hard Case Cover in Retail Box + Free Screen Protector and Cleaning Cloth"},
{"id":"4895058314270", "title":"lighthouse design | Super Mario Bros Earphones Headphones for MP3 MP4 PC iPHONE + 3 Pairs of Spare Earbuds"},
{"id":"087956908", "title":"GreatShield Anti-Glare Clear Screen Protector Film for Apple iPhone 4S (3/Pack w/ 1 Bonus Back Film)"},
{"id":"0888063", "title":"2 Port USB Car Charger Adapter +SB Cable For Apple iPhone 3G 3Gs 4G 4Gs, iPad,iPad 2"},
{"id":"5941181", "title":"wireless accessories | Case Cover Butterflies Purple and Silver For Apple iPhone 4 4S AT&T and Verizon"},
{"id":"0088515837854", "title":"EVO Power iPod Car Charger+USB Date Cable+AV TV Video RCA Cable for Apple iphone ipod touch"},
{"id":"0608938440334", "title":"Black USB Wall Charger+10ft Extra Long SYNC Cable Cord For Apple iPod, iPhone (All Models), iPad 2G"},
{"id":"0689466130973", "title":"PINK Color USB Travel Kit with Car Charger, Wall Charger and USB SYNC Cable for Apple iPod & iPhone"},
{"id":"0689466175554", "title":"10W USB Wall Charger Power Adapter for Apple iPad 1G 2G (Also works with iPhone & iPod) NEWBO Brand."},
{"id":"0689466453577", "title":"Black USB Wall Charger + 10ft (TEN FEET !) Extra Long SYNC Cable Cord For Apple iPod & iPhone (All models)"},
{"id":"0817211014883", "title":"6FT 1/8 3.5MM Stereo Audio Extension Patch Cable Plug Mini Jack M/M For iPhone iPad iPod"},
{"id":"0879569084673", "title":"GreatShield Anti-Glare Clear Screen Protector Film for Apple iPhone 4S (3/Pack w/ 1 Bonus Back Film)"},
{"id":"0886610465084", "title":"eForCity White Hole Back Rubberized Hard Cover Case+Travel Charger Compatible with iPhone® 4 4G 4th 4S"},
{"id":"0888063791093", "title":"2 Port USB Car Charger Adapter +SB Cable For Apple iPhone 3G 3Gs 4G 4Gs, iPad,iPad 2"},
{"id":"5941181006816", "title":"wireless accessories | Case Cover Butterflies Purple and Silver For Apple iPhone 4 4S AT&T and Verizon"},
{"id":"8852240010071", "title":"Toy Story iphone Cases | Deco Fairy Toy Story Buzz Light Year Woody Alien 3 Eyes Hard Case Cover"},
{"id":"087708412", "title":"Apple® iPhone® 4 Rubberized Dark Purple Premium Phone Protector Hard Cover Case + USB Car Charger Adapter white"},
{"id":"0033991029736", "title":"Scosche flipSYNC Charge and Sync Cable - for iPhone, iPod - 1 x Male USB - 1 x Male Proprietary Connector - White"},
{"id":"0848048025506", "title":"Mini USB Car Charger Adapter + Data Charge Cable For Iphone 4 4G 3 3G 3GS / iPod Touch / iPod Nano"},
{"id":"0877084128391", "title":"Apple® iPhone® 4 Rubberized Dark Purple Premium Phone Protector Hard Cover Case + USB Car Charger Adapter white"},
{"id":"0885157583350", "title":"EZOPower 2-Port External Backup Battery Portable Charger + EZOPower 6ft USB Sync & Charge Cable for Apple iPod iPhone iPad"},
{"id":"0885157583374", "title":"EZOPower 2-Port External Backup Battery Portable Charger + EZOPower 6ft USB Sync & Charge Cable for Apple iPod iPhone iPad"},
{"id":"0689466", "title":"Davis & Sanford Vista Connex Quick Connect Tripod with Ball Head & iPhone Holder with Lenspen Mini + Spudz Cloth + CleanDR Cleaning Kit"},
{"id":"0689466549843", "title":"Davis & Sanford Vista Connex Quick Connect Tripod with Ball Head & iPhone Holder with Lenspen Mini + Spudz Cloth + CleanDR Cleaning Kit"},
{"id":"8801154513673", "title":"More Toy Story | PIXAR Monster Factory INC Sulley Hard Case for iPhone 4 4S + deco-fairy branded LCD screen protector"},
{"id":"087708410", "title":"Universal Apple® USB Charger Kit - 12v Car + Wall Charger (White) for iPod®, iPhone®, iPod touch®, iPod nano®"},
{"id":"0877084106054", "title":"Universal Apple® USB Charger Kit - 12v Car + Wall Charger (White) for iPod®, iPhone®, iPod touch®, iPod nano®"},
{"id":"8690637018916", "title":"THE-SECURITY-STORE | Earpiece for Iphone 5, 4, 4s (Pack of 4 pcs. Bodyguard Style Covert Acoustic Tube Headset with HQ Microphone)"},
{"id":"0886610060890", "title":"Snap-on Rubberized Cases Covers ( Purple, White, Hot Pink, Black ) + LCD Screen Protector Guard Shield Protective Film Kit compatible with iPhone® 4 / 4S"},
{"id":"8000500", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Disney Character 3D Stitch / Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack"},
{"id":"958880033", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Disney Character 3D Winnie / Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack"},
{"id":"8000500164457", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Disney Character 3D Stitch / Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack"},
{"id":"9588800335108", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Disney Character 3D Winnie / Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack"},
{"id":"0885157601252", "title":"EZOPower EZCH12 2-Port USB Car / Wall / AA / 9V Universal 4-Way Charger + EZOPower EZMFI11 USB Sync & Charge Dock Connector Cable for Apple iPod iPhone iPad"},
{"id":"0885157566803", "title":"iKross Bluetooth Headset + Car Mount Holder for Apple® iPhone 5, Samsung Galaxy S3/S III, Samsung Galaxy S2/S II and Other Android Cell Phone, Smartphone, and more"},
{"id":"4892396400283", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Crystal Pink Giraffe/ Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack (With Cutely Gift Box)"},
{"id":"9588800330561", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Lovely Starbucks Hot Pink Coffee Cup Style/ Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack"},
{"id":"69386269", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Orange Crystal Angry Bird / Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack (With Cutely Gift Box)"},
{"id":"6938626910011", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Orange Crystal Angry Bird / Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack (With Cutely Gift Box)"},
{"id":"489704195", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Diamond White Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"4901830", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Diamond Grenn Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"955617348", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Crystal Green Rabbit/ Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"4891444300353", "title":"shelley.kz | Dust Plug- Earphone Jack Accessories Disney Character 3d Minnie Mouse/ Cell Charms / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack (1 Pc Minnie Only)"},
{"id":"4897041950168", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Diamond White Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"4901830154306", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Diamond Red Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"4901830156607", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Diamond Grenn Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"9556173481289", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Crystal Green Rabbit/ Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"471280380", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Pink Crystal Queen Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"4901243", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Crystal Purple Cross Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"4712803801697", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Pink Crystal Queen Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"4809010272027", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Green Crystal Queen Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"4901243120684", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Crystal Purple Cross Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"6909442", "title":"shelley.kz | Ultra Thin Solar Powered/usb/wall Outlet 3 in 1 with High Capacity 2600mah) Backup Battery Charger for Cell Phones, Iphone, Ipod, and Most USB Powered Devices - External, Portable, Rechargeable--silver"},
{"id":"0885909528851", "title":"Iphone 4s Smartphone Wi-fi Bar Black At&t Ios 5 Lcd 640 X 960 Touchscreen Multi-touch Screen 8 Megapixel Camera Quad Band Gps Reciever Bluetooth Usb 14 Hour Talk Time"},
{"id":"0885909528875", "title":"Iphone 4s Smartphone Wi-fi Bar White At&t Ios 5 Lcd 640 X 960 Touchscreen Multi-touch Screen 8 Megapixel Camera Quad Band Gps Reciever Bluetooth Usb 14 Hour Talk Time"},
{"id":"6909442201133", "title":"shelley.kz | Ultra Thin Solar Powered/usb/wall Outlet 3 in 1 with High Capacity 2600mah) Backup Battery Charger for Cell Phones, Iphone, Ipod, and Most USB Powered Devices - External, Portable, Rechargeable--silver"},
{"id":"471150730", "title":"shelley.kz | Blue- Color Series Premium Headphone Headset Earbud Earphone with Microphone and Volume Control for Apple Iphone s 4 4s Ipod Touch Itouch New Ipad 2 Ipad 3 (Multi-color Available)-blue 1pc"},
{"id":"4711507301083", "title":"shelley.kz | Blue- Color Series Premium Headphone Headset Earbud Earphone with Microphone and Volume Control for Apple Iphone s 4 4s Ipod Touch Itouch New Ipad 2 Ipad 3 (Multi-color Available)-blue 1pc"},
{"id":"6909442201119", "title":"shelley.kz | Dust Plug-earphone Jack Accessories Lake Blue Small Crystal Queen Crown / Cell Charms / Dust Plug / Ear Jack for Iphone 4 4s / Ipad / Ipod Touch / Other 3.5mm Ear Jack(with Cutely Gift Box)"},
{"id":"0886489454509", "title":"Skque Car Charger With Cable-2100mA Output + Black Apple ipod Nano 3.5mm Stereo with mic Headset + Red Hot Sell iPAD/iphone/iPod Galaxy Aluminum Capacitive Stylus Pen for Samsung Galaxy Tab 2 7.0 Inch Tablet"},
{"id":"0886489454486", "title":"Skque Car Charger With Cable-2100mA Output + Black Apple ipod ipod Nano 3.5mm Stereo with mic Headset + Black Hot Sell iPAD/iphone/iPod Galaxy Aluminum Capacitive Stylus Pen for Samsung Galaxy Tab 2 7.0 Inch Tablet"},
{"id":"0885157563185", "title":"EZOPower EZSK10 4-Port Car Cigarette Lighter Socket Adapter with USB Charging Port + 2 X Micro-USB Car Charger for Samsung Galaxy S III i9300 , I535 , L710 , T999 , I747 ; Apple iPhone 3G S , 3G , 4 , 4S & more"},
{"id":"0885157563192", "title":"EZOPower EZSK10 4-Port Car Cigarette Lighter Socket Adapter with USB Charging Port + 4 X Micro-USB Car Charger for Samsung Galaxy S III i9300 , I535 , L710 , T999 , I747 ; Apple iPhone 3G S , 3G , 4 , 4S & more"},
{"id":"0885909343874", "title":"Iphone 4 Smartphone At&t Quad Band Gsm 850 Gsm 900 Gsm 1800 Gsm 1900 Wcdma 850 Wcdma 900 Wcdma 1900 Wcdma 2100 Bluetooth Wi-fi Gprs Edge Hsdpa Hsupa Polyphonic True Tone 16.7 Million Colors 16gb Bar Black"}
]'

Query for iPhone

curl 'http://localhost:8983/api/c/products/select?q=title:iphone&fl=id,title'

{
  "response":{"numFound":259,"start":0,"docs":[
  {
    "id":"5000147030156",
    "title":["bargains4you | Bargains4You Iphone 4, Iphone ... Boosters X 2"]},
  {
    "id":"0602956",
    "title":["Marware Membrane iPhone Case - iPhone - Smoke - Polypropylene"]},
  {
    "id":"0602956009542",
    "title":["Marware Membrane iPhone Case - iPhone - Smoke - Polypropylene"]},
  {
    "id":"087956904",
    "title":["Fosmon iPhone Case - iPhone - Purple - ... Polyurethane (TPU)"]},
  {
    ...
}}

As you can see, the results here are all over the place in terms of relevance to user expectations. Usually, the intent of such queries are to explore the actual phone referred to as “iphone”, instead of cases and accessories for iPhone.

Adding payloads

Assume that we have gathered clickstream statistics through offline processing and we know the click count for a <query, document> pair. Using payloads, we can associate the query and number of clicks (for that query) for each of the products. Here’s an example (for one of the most popular products):

curl -X POST 'http://localhost:8983/solr/products/update?commit=true' \
-d '[{"id":"0885909459865", "queries_dpf": {"set": "iphone|20 apple|15"}}]'

Here, queries_dpf is a dynamic float payload field. The above represents the scenario that the product “0885909459865” was clicked 20 times for the query “iphone” and 15 times for the query “apple”.

Sorting the results by the payload

To let the click counts participate in the ranking of the results, we can sort the results by a payload function: payload(queries_dpf,iphone,0). The first parameter is the payload field name, the second is the term that has the payload and the last is the default payload value (in case there is no payload for that term).

curl \
'http://localhost:8983/api/c/products/select?q=title:iphone&amp;fl=id,title,payload(queries_dpf,iphone,0)&amp;sort=payload(queries_dpf,iphone,0)%20desc,score%20desc&amp;rows=300'

{
 "response":{"numFound":259,"start":0,"docs":[
 {
  "id":"0885909459865",
  "title":["Iphone 4s 32gb Black White"],
  "payload(queries_dpf,iphone,0)":20.0},
 {
  "id":"5000147030156",
  "title":["bargains4you | Bargains4You ... Wifi Boosters X 2"],
  "payload(queries_dpf,iphone,0)":0.0},
 {
  "id":"0602956",
  "title":["Marware Membrane iPhone Case ... Polypropylene"],
  "payload(queries_dpf,iphone,0)":0.0},
 { ...
   ...}]
}

As you can see, the most clicked document for the query “iphone” was shown first, leading to a much more relevant user experience.

Instead of sorting, you could also use the payload function in scoring as well. Also, you can filter by payloads. Check out the reference guide for the payload query parsers or the payload function.

Leave a Reply

Your email address will not be published. Required fields are marked *