Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elastic{ON} 2018 - Improving Customer Experienc...

Elastic Co
March 01, 2018

Elastic{ON} 2018 - Improving Customer Experience with Geo Capabilities at the UK’s Biggest Property Portal

Elastic Co

March 01, 2018
Tweet

More Decks by Elastic Co

Other Decks in Technology

Transcript

  1. Rightmove Group Ltd 1st March 2018 @trev_boxmonster Improving Customer Experience

    with Geo Capabilities at the UK’s Biggest Property Portal Adrian McMichael, Lead Architect
  2. Agenda 2 1 History of Elasticsearch at Rightmove 2 Using

    Geo-search to find documents 3 Using Percolators to alert users 4 Support with the Elastic Stack 5 Bright Ideas
  3. 4 Tis is a sample image UK’s Largest Property Portal

    • Established in 2000 • Help users find their next house • Help estate agents and lettings agents advertise their stock • Help agents find vendors • Around 55 million visits a day • 1.2 million properties on site • Over 90% of all estate agents in the UK
  4. • Property Search • Sold Price Search and Analysis •

    Property Alerts • Customer reporting • Supporting our site and applications • On Elasticsearch version 5.6 • 3 cluster types per datacentre for 3 datacentres • Search • Generic • Logging How we use Elasticsearch? 5
  5. 7 Tis is a sample image Fear the unknown! Black

    Box Search • Old proprietary search software • Master-Slave model that didn’t scale • Had to take cluster offline to re-index • Re-index every night to keep it working • Adding more nodes made it slower • Missing Features • Rolled our own geo-code and caching • Developer fear == No changes
  6. 8 Tis is a sample image God of the Hunt

    Enter Project Odin • Investigated new search engine • Solr Vs Elasticsearch • Elasticsearch Wins! • Faster to index • Easier to work with • Had features we wanted • Easier to scale • Introduced Microservices to Rightmove!
  7. 10

  8. 12 Tis is a sample image Our use-cases Geo Search

    at Rightmove • User searches • Map-search • Draw-a-search • Allowing users to draw their own areas • Sold Prices • Where-Can-I-Live • Finding what you can afford
  9. • Geo-Distance • Groups results within distance of a central

    point • Geo-Polygon/Geo-Shape • Polygon/Shape based search for finding results within an area • Geo-Bounding Box • Efficient way of searching within a rectangle Types of Geo-Search 13
  10. 14 Tis is a sample image Geo Distance • Used

    for Point based searches • Current Location Search • Allows users to search on the go • Point of interest search • Allows users to search around stations • Sort by distance • Get the closest property to your work or travel • Requires geo_point type on a field • Format is lon,lat in array to match GeoJSON I want to live near this station!
  11. 15 curl –XGET localhost:9200/property-current/_search –d ‘ { "query":{ "bool":{ "must":{

    "match_all":{} }, "filter":{ "geo_distance":{ "distance":”5mi", ”address.location":{ "lat":40, "lon":-70 } } } } } } Geo Distance Search Example
  12. 16 Tis is a sample image I want to live

    in this area! Geo Polygon and Geo Shape • Used for Region, City, Outcode and Drawn area searches • Started with Geo-Polygon but moved to Geo-Shape for performance • Simplify Your Polygons • Complex shapes have a hit on performance and are rarely needed. • Sampling techniques can be used to keep shapes simple. • Store your shapes
  13. • Geo Polygon searches will only ever include points that

    fall within the polygon provided but do so at a cost. • Geo Shape searches use a geo-hashing technique that results in Elasticsearch performing text searches. • Paint geo-shapes onto a grid where each square has a co-ordinate. • A shape is translated into these coordinates, or geo-hashes and we look for documents that have hashes that match, essentially doing a text search. • Tune accuracy via setting to correct precision. • Don’t set millimeter accuracy when the points you are searching are the size of a house! • Geo-shapes can’t be used in sorting, scoring or aggregations Geo-Shape Vs Geo-Polygon 17 Performance vs Accuracy
  14. 18 • Blog post here: https://www.elastic.co/blog/supercharging- geopoint See the video

    here: https://www.youtube.com/watch?v=l2zB9TD UAL4&feature=youtu.be Breaking polygons down into squares Geo Hashing Example
  15. 19 curl –XGET localhost:9200/property-current/_search –d ‘ { "query":{ "bool":{ "must":{

    "match_all":{} }, "filter":{ "geo_polygon":{ ”address.location":{ "points":[ { "lat":40, "lon":-70 }, {"lat":30, "lon":-80 },{ "lat":20, "lon":-90 } ] } } } }}}’ Requires a geo_point field Geo-Polygon Example
  16. 20 curl –XGET localhost:9200/pal-location-current/_search –d ‘ { "query":{ "bool":{ "must":{

    "match_all":{} }, "filter":{ "geo_shape":{ "geometry":{ "shape":{ "type" : "polygon", "coordinates" : [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] ] }, "relation":"intersects" } } } }}}’ Requires a geo_shape field Geo-Shape Example
  17. 21 Tis is a sample image I want to browse

    an area on a map! Bounding Box Search • Fastest form of Geo-search • Does less than and greater than comparison • Uses Top-Left and Bottom-Right coordinates • Compares these to the locations under search using less than or greater than. • Excellent for map-search • The user’s viewport/screen is always a rectangle • Makes searching while panning around a map quick.
  18. 22 curl –XPUT localhost:9200/property-current/_search –d ‘ { "query":{ "bool":{ "must":{

    "match_all":{} }, "filter":{ "geo_bounding_box":{ "pin.location":{ "top_left":{ "lat":40.73, "lon":-74.1}, "bottom_right":{ "lat":40.01, "lon":-71.12} } } } } } } Requires geo_point field Bounding-Box Example
  19. 23 Tis is a sample image Building Property Search Putting

    it together • Use Geo Shapes to search within an area • Use Geo Distance searches with a radius when the user searches based on a station or current location or sorting • Be smart with map-searches • When a user zooms or pans within a shape on a map search then use Bounding Box search • Combine viewports with geometry to do partial areas for map search • Don’t Geo search when you don’t have to! • Text search for exact postcode and outcodes on list search
  20. 26 Tis is a sample image Reverse-Searching Percolators • Percolate

    Queries: • Allow you to index queries • Match documents against the indexed queries instead of the other way around. • Property is matched against the saved searches • We have around 3.5 million saved searches. • 2.5 million Property alert emails a day. • 850,000 locations matched across • Running 1 billion percolate queries a week to create matches for alerts on a cluster of 3 data nodes.
  21. 27 curl –XPUT localhost:9200/alerts-index –d ‘ { “mappings” : “_doc”

    : { “properties” : { “features”: { “type” : “text” }, “query”: { “type” : “percolator” } } } }’ Creates an index that can be used for percolate queries Create a percolator index
  22. 28 curl –XPUT localhost:9200/alerts-index/queries/1 –d ‘ { “query” : “match”

    : { “features”: “garden” } } }’ Match on messages we want to be notified about Index a Query
  23. 29 curl –XPUT localhost:9200/alerts-index/_search –d ‘ { "query": { "percolate":

    { "field":"query", "document_type":"doctype", "document":{ ”features":[”beautiful garden", ”off-street parking"] } } } }’ Find if a message matches the queries we have stored Try to Find a Match
  24. • Percolate queries become more expensive as the number of

    them increases • We mitigate this by filtering down the queries before percolating • Filter by: • Transaction type – e.g. buy or rent • Location Key – Combine location type, id and radius e.g. outcode-1234-0.25 • By only running the percolate query against these candidate indexed queries we know match the same locations or transaction types as the property documents we are comparing we keep each percolate query down to 1000s at most instead of millions. Percolating at scale 30 Searching over millions of queries
  25. Support With the Elastic Stack The effect of the Elastic

    Stack on Microservice Development support
  26. 36 Tis is a sample image The challenges Supporting Microservices

    • 50+ microservices in production • Continuous Deployments instead of 2 weekly releases • Microservices bring us the potential for easier tracing of issues, but only if we get our monitoring right • We generate almost 7.3 Billion log messages a day
  27. • Queryable • Keep logs in indices by type not

    per application. Allows following requests across application boundaries • Flexible • Support dynamic key-values and tags against every log message • Consistent • Promote common log formats using shared logging libraries written to a JSON specification • Easy to configure • We use Git to store Logstash configuration and provide common templates to minimize boilerplate • Separately deployable • Built scripted Jenkins pipelines to deploy log configuration changes Log Collation Requirements 37 Making logging maintainable and useful
  28. • Access Log • Logs each incoming request as it

    completes along with relevant metadata • Client Response Log • Logs outgoing requests from a consuming service to its provider along with the corresponding response time • Error Log • Logs errors with their stack-traces, causes and relevant metadata • App Log • Logs generic application messages useful for cross correlating activity with requests and errors Log Types 38 Using Common Formats across services
  29. 40 Tis is a sample image Looking after microservice Supporting

    Developers • Provide Elastic Stack Docker Compose stack for development • Wrap up common Logstash/Watcher configuration • Use templates • Wrap Watcher/Alerting with forms • Educate • Elastic Training • Internal Workshops • Evangelise!
  30. 41

  31. 42

  32. 44 Tis is a sample image Where Can I Live?

    Helping Users Start Their Journey • Users often looking for how to start their property search. • Have a budget or mortgage in principal. • Have a minimum number of bedrooms they need for their family. • Have places they need to be near like work. • We used these factors and Elasticsearch to build a special tool to help these users.
  33. 46

  34. 47

  35. 48

  36. 49