Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Solr Cluster installation tool "Anuenue"


Published on

Mixi is one of the largest social networking services in Japan, providing various communication services for over 14M monthly active users. The latest internal mixi project is to replace the in-house search engine with Apache Solr. This session covers two topics; a simple packaging system for Solr that eases the installation process and daily operations, and implementation of a "Did you mean" facility for Japanese queries using a log mining tool. These tools have been released as OSS projects.

Published in: Technology
  • Be the first to comment

Solr Cluster installation tool "Anuenue"

  1. 1. Solr Cluster installation tool "Anuenue" and "Did You Mean?" for Japanese Takahiko Ito mixi, Inc.
  2. 2. mixi? <ul><li>One of the largest social networking service in Japan. </li></ul><ul><li>Many services to promote communication among users. </li></ul><ul><ul><li>Blog, news, game platform etc </li></ul></ul><ul><ul><li>Most of the services come with search </li></ul></ul><ul><li>15M monthly active users </li></ul>
  3. 3. Our current (urgent) project … <ul><li>Replace in-house search engines into a up-to-date search </li></ul><ul><li>platform! </li></ul><ul><li>We have </li></ul><ul><ul><li>selected Apache Solr as the search platform! </li></ul></ul><ul><ul><li>created a simple OSS package ( Anuenue ) which wraps Solr </li></ul></ul><ul><li>Project URL: </li></ul>
  4. 4. Reason why we make Anuenue <ul><li>Deployment / daily operations of Solr search cluster is a bit </li></ul><ul><li>difficult for ordinary engineers. </li></ul><ul><ul><li>We need to edit the configuration files for all the Solr instances respectively </li></ul></ul><ul><ul><li>Commands for whole clusters are not provided </li></ul></ul><ul><ul><ul><li>We need to write client commands by ourselves </li></ul></ul></ul><ul><ul><ul><li>Hadoop provides utility commands for clusters </li></ul></ul></ul><ul><ul><ul><li>E.g., (start processes),  fsck (check all discs), balancer (rebalance the data blocks) </li></ul></ul></ul>
  5. 5. What does Anuenue provide? <ul><li>Handy configuration of search clusters </li></ul><ul><li>Commands for clusters </li></ul><ul><ul><li>Simple commands (post, delete, update, commit etc) </li></ul></ul><ul><ul><li>Start and stop commands for processes in cluster. </li></ul></ul><ul><li>Japanese support </li></ul><ul><ul><li>Implementation of Japanese Did-You-Mean facilities </li></ul></ul><ul><ul><li>Japanese tokenizer (Sen and Kuromoji) </li></ul></ul>
  6. 6. Today’s Topics <ul><li>Anuenue </li></ul><ul><ul><li>Handy configuration of search clusters </li></ul></ul><ul><ul><li>Commands for search clusters </li></ul></ul><ul><li>Did-You-Mean facilities for Japanese queries </li></ul><ul><ul><li>Common problem in Did-You-Mean implementation </li></ul></ul><ul><ul><li>Mining a Japanese Did-You-Mean dictionary from query log data </li></ul></ul>
  7. 7. Cluster configuration with Anuenue <ul><li>Cluster setup is done with a special configuration file </li></ul><ul><li>Anuenue assigns more than one roles to instances. </li></ul><ul><ul><li>Roles are the functions in a cluster </li></ul></ul><ul><ul><li>Anuenue supports three roles ( Master, Slave, Merger ) </li></ul></ul>
  8. 8. Role: master <ul><li>Index input data. </li></ul><ul><li>NOTE : Anuenue provides a command to distribute the input </li></ul><ul><li>data into master instances (build Solr shard indexes) . </li></ul>Input Data Master-1 Master-2 Master-3 Build shard indexes
  9. 9. Role: slave <ul><li>Has three functions </li></ul><ul><ul><li>Copy (replicate) index from master </li></ul></ul><ul><ul><li>Accept queries from mergers and then search it own index </li></ul></ul><ul><ul><li>Return the results to merger instance </li></ul></ul>Input Data Slave-1 Slave-2 Merger-1 Submit queries Replicate index Master-1 Master-2 Index input data
  10. 10. Role: merger <ul><li>Forwards queries from clients to slaves. </li></ul><ul><ul><li>Note: clients need not to know the slave instances (merger adds ‘shard’ parameter with slave instances) </li></ul></ul><ul><li>Merge the results from all the slave instances and returned the merged results. </li></ul>Slave-1 Slave-2 Merger Forwards queries Client-1 Client-2 Submit queries
  11. 11. Example: Anuenue cluster <ul><li>The cluster consists of five </li></ul><ul><li>machines </li></ul><ul><ul><li>Each has one Anuenue instance </li></ul></ul><ul><li>Instances </li></ul><ul><ul><li>Merger: aa </li></ul></ul><ul><ul><li>Master: bb, cc </li></ul></ul><ul><ul><li>Slave: dd, ee </li></ul></ul>Input Data bb ee cc dd aa Forward queries Index input data Client-1 Client-2 Replicate index
  12. 12. How to assign roles to instance? <ul><li>Edit cluster configuration file, anuenue-nodes.xml . </li></ul><ul><ul><ul><li>Add three elements (mergers, slaves and masters) </li></ul></ul></ul><ul><ul><ul><li>In each element, add more than one instance information ( machine name and port number ). </li></ul></ul></ul>
  13. 13. Configuration example <ul><li>Case: there is one merger instance in machine, aa (port </li></ul><ul><li>7000) </li></ul><ul><li><mergers> </li></ul><ul><li><merger> </li></ul><ul><li>< host >aa</ host > </li></ul><ul><li>< port >7000</ port > </merger> </li></ul><ul><li></mergers> </li></ul>
  14. 14. Specify the index to replicate <ul><li><masters> </li></ul><ul><li><master iname =“ master1 ”> </li></ul><ul><li><host>aaaa</host> </li></ul><ul><li><port>8983</port> </li></ul><ul><li></master> </li></ul><ul><li></masters> </li></ul><ul><li><slaves> <slave > <host>bbbb</host> <port>8983</port> </li></ul><ul><li>< replicate > master1 </ replicate > </slave> </li></ul><ul><li></slaves> </li></ul>Add name of master instance by iname attribute Specify the master instance to copy the index adding replicate element
  15. 15. Example: simple cluster settings Input Data bb cc aa Forward queries Index input data Client-1 Client-2 <mergers> <merger> <host>aa</host> <port>8983</port> </merger> </mergers> <masters> <master iname=“master1”> <host>bb</host> <port>8983</port> </master> </masters> <slaves> <slave> <host>cc</host> <port>8983</port> <replicate>master1</replicate> </slave> </slaves> Replicate index
  16. 16. Cluster setup with Anuenue <ul><li>Flexible and support various types of search cluster. </li></ul><ul><li>For example… </li></ul>
  17. 17. Assign multiple roles Input Data instance Client1 Client2 Index input data Submit queries
  18. 18. Large clusters to handle huge data with high QPS Input Data Client1 Slave1 Client2 Merger1 Slave3 Slave2 Slave4 Master1 Master2 Slave5 Slave6 Master3 Master4 Master5 Master6 Merger2 Merger3 Client3 ClientN …
  19. 19. After setting up cluster <ul><li>We can make use of commands for clusters. </li></ul><ul><li>Anuenue provides </li></ul><ul><ul><li>start / stop commands </li></ul></ul><ul><ul><li>commands to manipulate the index </li></ul></ul>
  20. 20. Start and stop clusters <ul><li>Users can start / stop clusters by a command </li></ul><ul><li>( </li></ul><ul><li>Usage: </li></ul><ul><li>$sh bin/ [start|stop] </li></ul>
  21. 21. Simple commands for clusters <ul><li>Anuenue also provides basic commands (‘ post ’, ‘ delete ’, </li></ul><ul><li>‘ commit ’, ‘ optimize ’ and ‘ update ’) for search cluster   </li></ul><ul><ul><li>The commands are implemented in multi-thread </li></ul></ul><ul><li>E.g., </li></ul><ul><li>$sh bin/ post -arg inputDir </li></ul>
  22. 22. Today’s Topics <ul><li>Anuenue </li></ul><ul><ul><li>Handy cluster configuration of search clusters </li></ul></ul><ul><ul><li>Commands for search clusters </li></ul></ul><ul><li>Did-You-Mean facilities for Japanese queries </li></ul><ul><ul><li>Common problem in Did-You-Mean implementation </li></ul></ul><ul><ul><li>Mining a Japanese Did-You-Mean dictionary from query log data </li></ul></ul>
  23. 23. What is Did-You-Mean service? <ul><li>Suggest correct spelling when users submit queries with mistakes </li></ul><ul><li>Increase the usability of search service </li></ul>
  24. 24. Example: Did-You-Mean service (English: Ugly Betty)
  25. 25. Common implementation <ul><li>Many search engines (including Solr) apply distance </li></ul><ul><li>measures such as Edit Distance [Levenshtein, 1965] </li></ul><ul><li>Edit Distance : measure of distance between two sequences. </li></ul><ul><li>Simply speaking, when two sequences have more common </li></ul><ul><li>characters, the distance is smaller. </li></ul><ul><li>E.g., </li></ul><ul><li>like  likes (small distance) </li></ul><ul><li>like  foobar (large distance) </li></ul>
  26. 26. Common procedure: Did-You-Mean <ul><li>When a user submits a query, </li></ul><ul><li>Did-You-Mean service computes edit distance between input query and words in index. </li></ul><ul><li>If there is a word whose distance is small, </li></ul><ul><ul><ul><li>Did-You-Mean handler suggests </li></ul></ul></ul><ul><li>E.g., when a user submit a query, “pthon”, Did-You-Mean </li></ul><ul><li>service suggests a word in the index with small distance </li></ul><ul><li>“ python”. </li></ul>
  27. 27. Problem: Japanese queries <ul><li>Simple application of edit distance does not work for </li></ul><ul><li>Japanese </li></ul><ul><li>Misspelled queries are sometimes totally different from the correct one ( large distance ). </li></ul><ul><ul><li>E.g., </li></ul></ul><ul><ul><li>墨ともふどうさん (correct: 住友不動産 ) </li></ul></ul><ul><ul><li>米事案セット (correct: ベイジアンセット ) </li></ul></ul><ul><li>These cases are derived from Japanese input method . </li></ul>
  28. 28. Typing in Japanese query <ul><li>We input Japanese (query) words with two steps. </li></ul><ul><ul><li>Type the reading of the Japanese word in Latin alphabet. </li></ul></ul><ul><ul><li>Select a desired word from the list of candidates </li></ul></ul>This step cause a spelling mistake, too large distance to correct spelling
  29. 29. Example: Typing in Japanese queries <ul><li>Assume a user wants to submit a query: </li></ul><ul><li>オバマ (Obama) </li></ul><ul><li>Type in the reading in Latin alphabet. </li></ul><ul><li>reading : obama </li></ul><ul><li>Select correct spelling. </li></ul><ul><li>Possible candidates : オバマ ( correct ), おばま , 小浜 etc. </li></ul>
  30. 30. Japanese Did-You-Mean dictionary <ul><li>Because of the large distance problem, simple distance measures (edit distance) do not work. </li></ul><ul><li>To handle this problem, Anuenue supports a special dictionary for Japanese Did-You-Mean service. </li></ul>
  31. 31. Dictionary for Japanese Did-You-Mean service <ul><li>Dictionary has two columns </li></ul><ul><ul><li>Query with mistakes </li></ul></ul><ul><ul><li>Correct queries </li></ul></ul>Query with mistakes Correct Query 墨ともふどうさん 住友不動産 歌だ光る 宇多田ヒカル 米事案セット ベイジアンセット
  32. 32. Implementing Did-You-Mean service with the dictionary <ul><li>When users submit the </li></ul><ul><li>query with mistakes in </li></ul><ul><li>dictionary, </li></ul><ul><li>Did-You-Mean service suggests the correct query </li></ul><ul><li>NOTE : Anuenue provides </li></ul><ul><li>handlers for the dictionary </li></ul><ul><li>format. </li></ul>Query with mistakes Correct Query 墨ともふどうさん 住友不動産 歌だ光る 宇多田ヒカル 米事案セット ベイジアンセット
  33. 33. Problem… <ul><li>How we can create the dictionary? </li></ul><ul><li>We can make use of a query log mining tool Oluolu . </li></ul>
  34. 34. Oluolu <ul><li>Creates a spelling correction dictionary from query log </li></ul><ul><li>Extracts pairs of queries (query with spelling mistakes, query with correct spelling) </li></ul><ul><ul><li>Support the Japanese spelling mistakes (from version 0.2) </li></ul></ul><ul><li>runs on the Hadoop framework </li></ul><ul><li>Project URL: </li></ul>
  35. 35. Input to Oluolu: query log <ul><li>Three columns </li></ul><ul><ul><li>User Id </li></ul></ul><ul><ul><li>Query string </li></ul></ul><ul><ul><li>Time of query submission </li></ul></ul>User Id Query Time 438904 Pthon 2009-11-21 11:16:12 34443 Java 2009-11-21 12:16:13 438904 Python 2009-11-21 12:16:20 8975 Java Tomcat 2009-11-21 12:16:25
  36. 36. Procedure: creating Japanese Did-You-Mean dictionary with Oluolu <ul><li>Oluolu extracts the elements of Japanese Did-You-Mean </li></ul><ul><li>dictionary with 2 steps. </li></ul><ul><ul><li>Extract all the query pairs in the same session </li></ul></ul><ul><ul><li>Validate the query pairs </li></ul></ul>
  37. 37. Step1: extract query pairs <ul><li>Oluolu extracts pairs of queries in the same session . </li></ul><ul><li>E.g., Oluolu extracts pair (Pthon and Python). </li></ul><ul><li>Queries in the same session : a set of queries submit by the same user within small time range. </li></ul><ul><li>Extracted pairs can be misspelled query and correct query. </li></ul>User ID Query Time 438904 Pthon 2009-11-21 12:16:12 34443 Java 2009-11-21 12:16:13 438904 Python 2009-11-21 12:16:20 8975 Tomcat 2009-11-21 12:16:25
  38. 38. Step 2: validate candidate pairs <ul><li>Oluolu validates all the query pairs extracted step 1. </li></ul><ul><li>In validation phase (step 2), Oluolu makes use of query readings. </li></ul>
  39. 39. Reading of Japanese words <ul><li>Japanese words can be convert into the readings in Latin Alphabets. </li></ul><ul><ul><li>こんにちは (reading: konnichiha) </li></ul></ul><ul><ul><li>伊藤 (reading: itou) </li></ul></ul><ul><li>FACT : even when Japanese query with spelling mistakes </li></ul><ul><li>can be totally different from correct query, </li></ul><ul><ul><li>the readings are the same or the distance is small ! </li></ul></ul>
  40. 40. Validate candidate pair with reading <ul><li>Given a query pairs, Oluolu validates the queries with 2 </li></ul><ul><li>steps </li></ul><ul><ul><li>Convert the queries into readings with Latin Alphabets </li></ul></ul><ul><ul><li>Compute edit distance with the two readings </li></ul></ul><ul><ul><ul><li>When the distance is small, the two queries are extracted as a element of Did-You-Mean dictionary. </li></ul></ul></ul>
  41. 41. Example: step 2 <ul><li>Given a pair of queries: ( 墨ともふどうさん , 住友不動産 ) </li></ul><ul><li>Convert them into readings </li></ul><ul><ul><li>readings are the same, “sumitomofudousan”. </li></ul></ul><ul><li>Compute the distance with the readings </li></ul><ul><ul><li>Distance is zero </li></ul></ul><ul><ul><li>Extracted as a element of Did-You-Mean dictionary </li></ul></ul><ul><li> </li></ul>
  42. 42. Creating Japanese Did-You-Mean dictionary with Oluolu <ul><li>Installation requirements </li></ul><ul><ul><li>Java 1.6.0 or greater </li></ul></ul><ul><ul><li>Hadoop 0.20.0 or greater </li></ul></ul><ul><ul><li>Oluolu 0.2.0 or greater </li></ul></ul><ul><li>Copy the input query log into HDFS </li></ul><ul><li>Run spellcheck task of oluolu </li></ul><ul><li>$ bin/oluolu spellcheck </li></ul><ul><li>-input testInput.txt </li></ul><ul><li>-output output </li></ul><ul><li>-inputLanguage ja </li></ul>
  43. 43. Preliminary experiments <ul><li>Experimental settings </li></ul><ul><ul><li>Input data: log file from a mixi service (community search). </li></ul></ul><ul><ul><ul><li>5 GB data </li></ul></ul></ul><ul><li>Extracted dictionary </li></ul><ul><ul><li>number of elements is over 100.000 </li></ul></ul><ul><ul><li>succeeded to extract the query pairs with large edit distance. </li></ul></ul><ul><ul><ul><li>( 議 Ν, ギニュー ) </li></ul></ul></ul><ul><ul><ul><li>( 不動有利 , 不動裕理 ) </li></ul></ul></ul>
  44. 44. Current status <ul><li>Finished functional tests and stress tests. </li></ul><ul><li>Now replacing an in-house search engine in a small search service with Anuenue. </li></ul><ul><li>In next phase, we will apply Anuenue to the search service with large data and high QPS. </li></ul>
  45. 45. Future work <ul><li>Integrate SolrCloud and Zookeeper </li></ul><ul><ul><li>Support failover, and rebalance the index </li></ul></ul><ul><li>Kuromoji, a new OSS Japanese tokenizer </li></ul>
  46. 46. Summary <ul><li>Introduction of Anuenue </li></ul><ul><li>Described a Did-You-Mean facility for Japanese query </li></ul>
  47. 47. Thank you for your attention!