--- title: Hadoopチュートリアル シーズンII:7. SolrでYelpデータをインデックス、検索する方法 author: Hue Team type: post date: 2013-11-04T23:59:25+00:00 url: /hadoopチュートリアル-シーズンii:7-solrでyelpデータをインデ/ sf_thumbnail_type: - none sf_thumbnail_link_type: - link_to_post sf_detail_type: - none sf_page_title: - 1 sf_page_title_style: - standard sf_no_breadcrumbs: - 1 sf_page_title_bg: - none sf_page_title_text_style: - light sf_background_image_size: - cover sf_social_sharing: - 1 sf_sidebar_config: - left-sidebar sf_left_sidebar: - Sidebar-2 sf_right_sidebar: - Sidebar-1 sf_caption_position: - caption-right slide_template: - default sf_custom_excerpt: - 以前のエピソードでは、HBaseでPigとHiveを使用する方法を見てきました。今回は、Hue Search appがインデキシングによりYelpデータを検索できるようにするためにはどう... categories: - Full tutorial - Search - Tutorial - Video --- ([原文][1])
以前のエピソードでは、HBaseでPigとHiveを使用する方法を見てきました。今回は、Hue Search appがインデキシングによりYelpデータを検索できるようにするためにはどうするのか、カスタマイズ可能なユーザーインタフェースを構築するにはどうすれば良いのかについて見ていきます。
{{< youtube ATldKiiJdqY >}} # Solrにインデキシングデータを入れる このチュートリアルは[SolrCloud][2]に基づいています。これはSolrCloudのインストールと、必要となる[パッケージ][3]リストについてのステップバイステップ[ガイド][3]です: * solr-server * solr–mapreduce * search 次の手順はSolr Cloudのデプロイと設定についてです。[ドキュメント][4]に従いっていきます。 このあと、新しいコレクションと「reviews」という名前のインデックスを[作成][5]します。[Hadoop tutorial ][6][github][6]からコピーしておく必要がある、事前に定義されたスキーマを使用します。.cp solr_local/conf/schema.xml solr_configs/conf/schema.xml solrctl instancedir --create reviews solr_local solrctl collection --create reviews -s 1Yelpデータに対応するようにマッピングして、[スキーマ][7]にあるフィールドの定義を置き換えます。スキーマは、検索インデックスで利用可能なそれぞれのデータフィールドを表しています。schema.xmlについての詳細は[Solr wiki][8]を読んで下さい。
<field name="business_id" type="text_en" indexed="true" stored="true" /> <field name="cool" type="tint" indexed="true" stored="true" /> <field name="date" type="text_en" indexed="true" stored="true" /> <field name="funny" type="tint" indexed="true" stored="true" /> <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="stars" type="tint" indexed="true" stored="true" /> <field name="text" type="text_en" indexed="true" stored="true" /> <field name="type" type="text_en" indexed="true" stored="true" /> <field name="useful" type="tint" indexed="true" stored="true" /> <field name="user_id" type="text_en" indexed="true" stored="true" /> <field name="name" type="text_en" indexed="true" stored="true" /> <field name="full_address" type="text_en" indexed="true" stored="true" /> <field name="latitude" type="tfloat" indexed="true" stored="true" /> <field name="longitude" type="tfloat" indexed="true" stored="true" /> <field name="neighborhoods" type="text_en" indexed="true" stored="true" /> <field name="open" type="text_en" indexed="true" stored="true" /> <field name="review_count" type="tint" indexed="true" stored="true" /> <field name="state" type="text_en" indexed="true" stored="true" />続いて[Hiveのクエリ][9]でYelpデータのサブセットを取り出してきれいにし、CSVとしてダウンロードして、[インデクサツール][10]とこの[コマンド][11]でよりインデックスします::
hadoop jar /usr/lib/solr/contrib/mr/search-mr-*-job.jar org.apache.solr.hadoop.MapReduceIndexerTool -D 'mapred.child.java.opts=-Xmx500m' --log4j /usr/share/doc/search*/examples/solr-nrt/log4j.properties --morphline-file solr_local/reviews.conf --output-dir hdfs://localhost:8020/tmp/load --verbose --go-live --zk-host localhost:2181/solr --collection reviews hdfs://localhost:8020/tmp/query_result.csvコマンドは、Yelpデータをインデックスのschema.xmlに定義されたフィールドにマップするために、[morphlineファイル][12]を使用します。 morphlineをデバッグするには –dry-runオプションがいつの日か役立つでしょう。 # 検索結果をカスタマイズする 管理パネルでは、検索ページの見た目と機能の調整ができます。これはビデオの2番目のパートで説明されています。 # まとめ Cloudera Searchはあなたのユーザー基盤をHadoopに解放し、素早くデータの検索を行うために素晴らしいものです。その他のいくつかの記事では、[メール][13]や[顧客データ][14]の検索のような、いくつかの良いユーザー事例が述べられています。 Cloudera Morphline も、データのインデキシングを簡単にするための興味深いツールです。Morphlineについての詳細は、[プロジェクトのウェブサイト][15]で学ぶことができます。 いつものように、何かあれば[hue-user][16]メーリングリスト(英語)や、[@gethue][17]に気軽にコメントして下さい! # トラブルシューティング 1. このエラーをご覧になった場合:
org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:Error CREATEing SolrCore ‘reviews_shard1_replica1’: Unable to create core: reviews_shard1_replica1 Caused by: Could not find configName for collection reviews found:nullコレクションを作るのを忘れているのかもしれません:
solrctl instancedir --create review solr_configs2. このエラーをご覧になった場合:
ERROR - 2013-10-10 20:01:21.383; org.apache.solr.servlet.SolrDispatchFilter; Could not start Solr. Check solr/home property and the logs ERROR - 2013-10-10 20:01:21.409; org.apache.solr.common.SolrException; null:org.apache.solr.common.SolrException: solr.xml not found in ZooKeeper at org.apache.solr.core.ConfigSolr.fromSolrHome(ConfigSolr.java:109) Server is shutting downSolrに設定の再読み込みを強制する必要があるかもしれません。これはZooKeeperを壊してしまうかもしれず、3番目のエラーを読む必要があるかもしれないことに注意して下さい。 3. このエラーをご覧になった場合:
KeeperErrorCode = NoNode for /overseer/collection-queue-work</str> <str name="trace"> org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /overseer/collection-queue-workこれは2番目のエラーから来ているのかもしれません。設定を再アップロードし、コレクションを再作成する必要があるかもしれません。 [1]: https://gethue.com/hadoop-tutorials-season-ii-7-how-to-index-and-search [2]: http://wiki.apache.org/solr/SolrCloud [3]: http://www.cloudera.com/content/cloudera-content/cloudera-docs/Search/latest/Cloudera-Search-Installation-Guide/csig_install_search.html [4]: http://www.cloudera.com/content/cloudera-content/cloudera-docs/Search/latest/Cloudera-Search-Installation-Guide/csig_deploy_search_solrcloud.html [5]: http://www.cloudera.com/content/cloudera-content/cloudera-docs/Search/latest/Cloudera-Search-Installation-Guide/csig_runtime_solr_config.html [6]: https://github.com/romainr/hadoop-tutorials-examples/tree/master/solr-local-search [7]: https://github.com/romainr/hadoop-tutorials-examples/blob/master/solr-local-search/solr_local/conf/schema.xml#L109 [8]: http://wiki.apache.org/solr/SchemaXml [9]: https://github.com/romainr/hadoop-tutorials-examples/blob/master/solr-local-search/data_subset.sql [10]: http://www.cloudera.com/content/cloudera-content/cloudera-docs/Search/latest/Cloudera-Search-User-Guide/csug_batch_index_to_solr_servers_using_golive.html [11]: https://github.com/romainr/hadoop-tutorials-examples/blob/master/solr-local-search/load_index.sh [12]: https://github.com/romainr/hadoop-tutorials-examples/blob/master/solr-local-search/solr_local/reviews.conf [13]: http://blog.cloudera.com/blog/2013/09/email-indexing-using-cloudera-search/ [14]: http://blog.cloudera.com/blog/2013/09/secrets-of-cloudera-support-impala-and-search-make-the-customer-experience-even-better/ [15]: http://cloudera.github.io/cdk/docs/current/cdk-morphlines/index.html [16]: http://groups.google.com/a/cloudera.org/group/hue-user [17]: https://twitter.com/gethue