日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ElasticSearch-Hadoop:从Hadoop到ElasticSearch的产品视图计数索引和客户顶部搜索查询...

發布時間:2023/12/3 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ElasticSearch-Hadoop:从Hadoop到ElasticSearch的产品视图计数索引和客户顶部搜索查询... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這篇文章涵蓋了如何使用ElasticSearch-Hadoop從Hadoop系統讀取數據并在ElasticSearch中對其進行索引。 它涵蓋的功能是在最近n天中為每個客戶的產品瀏覽量計數和熱門搜索查詢編制索引。 分析的數據可以進一步在網站上使用,以顯示最近瀏覽過的客戶,產品瀏覽次數和熱門搜索查詢字符串。

繼續之前的文章

  • 客戶產品搜索使用大數據進行點擊分析 ,
  • Flume:使用Apache Flume收集客戶產品搜索點擊數據 ,
  • Hive:使用Apache Hive查詢客戶最喜歡的搜索查詢和產品視圖計數 。

我們已經有使用Flume收集并存儲在Hadoop HDFS和ElasticSearch中的客戶搜索點擊數據,以及如何使用Hive分析相同數據并生成統計數據。 在這里,我們將進一步了解如何使用分析后的數據來增強網站上的客戶體驗并使之與最終客戶相關。

最近瀏覽過的商品

我們已經在第一部分中介紹了如何使用水槽ElasticSearch接收器將最近查看的商品目錄索引到ElasticSearch實例,以及如何使用數據為客戶顯示實時點擊的商品。

彈性搜索-Hadoop

Elasticsearch for Apache Hadoop允許Hadoop作業通過小型庫和易于設置的方式與ElasticSearch進行交互。

Elasticsearch-hadoop-hive,允許使用Hive訪問ElasticSearch。 正如上一篇文章中所分享的那樣,我們在Hive表中提取了產品視圖計數以及客戶排名最高的搜索查詢數據。 我們將讀取相同的數據并將其索引到ElasticSearch,以便將其用于網站上的顯示目的。

產品視圖計數功能

采取一個方案來顯示客戶在最近n天中的每個產品總觀看次數。 為了獲得更好的用戶體驗,您可以使用相同的功能向最終客戶顯示其他客戶對同一產品的看法。

蜂房數據用于產品視圖

從配置單元表中選擇示例數據:

# search.search_productviews : id, productid, viewcount 61, 61, 15 48, 48, 8 16, 16, 40 85, 85, 7

產品視圖計數索引

創建Hive外部表“ search_productviews_to_es”以將數據索引到ElasticSearch實例。

Use search; DROP TABLE IF EXISTS search_productviews_to_es; CREATE EXTERNAL TABLE search_productviews_to_es (id STRING, productid BIGINT, viewcount INT) STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES('es.resource' = 'productviews/productview', 'es.nodes' = 'localhost', 'es.port' = '9210', 'es.input.json' = 'false', 'es.write.operation' = 'index', 'es.mapping.id' = 'id', 'es.index.auto.create' = 'yes'); INSERT OVERWRITE TABLE search_productviews_to_es SELECT qcust.id, qcust.productid, qcust.viewcount FROM search_productviews qcust;
  • 創建外部表search_productviews_to_es指向ES實例
  • 使用的ElasticSearch實例配置為localhost:9210
  • 索引“ productviews”和文檔類型“ productview”將用于索引數據
  • 如果索引和mappin不存在,則會自動創建
  • 如果基于ID字段已經存在,則插入覆蓋將覆蓋數據。
  • 通過從另一個存儲分析/統計數據的配置表“ search_productviews”中選擇數據來插入數據。

執行Java中的Hive腳本以索引產品視圖數據HiveSearchClicksServiceImpl.java

Collection<HiveScript> scripts = new ArrayList<>();HiveScript script = new HiveScript(new ClassPathResource("hive/load-search_productviews_to_es.q"));scripts.add(script);hiveRunner.setScripts(scripts);hiveRunner.call();

productviews索引樣本數據

ElasticSearch索引中的樣本數據存儲如下:

{id=48, productid=48, viewcount=10} {id=49, productid=49, viewcount=20} {id=5, productid=5, viewcount=18} {id=6, productid=6, viewcount=9}

客戶熱門搜索查詢字符串功能

以一種情況為例,您可能希望顯示單個客戶或網站上所有客戶的熱門搜索查詢字符串。 您可以使用它來顯示網站上的熱門搜索查詢云。

Hive Data用于客戶熱門搜索查詢

從配置單元表中選擇示例數據:

# search.search_customerquery : id, querystring, count, customerid 61_queryString59, queryString59, 5, 61 298_queryString48, queryString48, 3, 298 440_queryString16, queryString16, 1, 440 47_queryString85, queryString85, 1, 47

客戶熱門搜索查詢索引

創建Hive外部表“ search_customerquery_to_es”以將數據索引到ElasticSearch實例。

Use search; DROP TABLE IF EXISTS search_customerquery_to_es; CREATE EXTERNAL TABLE search_customerquery_to_es (id String, customerid BIGINT, querystring String, querycount INT) STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES('es.resource' = 'topqueries/custquery', 'es.nodes' = 'localhost', 'es.port' = '9210', 'es.input.json' = 'false', 'es.write.operation' = 'index', 'es.mapping.id' = 'id', 'es.index.auto.create' = 'yes'); INSERT OVERWRITE TABLE search_customerquery_to_es SELECT qcust.id, qcust.customerid, qcust.queryString, qcust.querycount FROM search_customerquery qcust;
  • 創建外部表search_customerquery_to_es指向ES實例
  • 使用的ElasticSearch實例配置為localhost:9210
  • 索引“ topqueries”和文檔類型“ custquery”將用于索引數據
  • 如果索引和mappin不存在,則會自動創建
  • 如果基于ID字段已經存在,則插入覆蓋將覆蓋數據。
  • 通過從另一個存儲分析/統計數據的配置單元表“ search_customerquery”中選擇數據來插入數據。

在Java中執行Hive腳本以索引數據HiveSearchClicksServiceImpl.java

Collection<HiveScript> scripts = new ArrayList<>();HiveScript script = new HiveScript(new ClassPathResource("hive/load-search_customerquery_to_es.q"));scripts.add(script);hiveRunner.setScripts(scripts);hiveRunner.call();

topqueries索引樣本數據

ElasticSearch實例上的topqueries索引數據如下所示:

{id=474_queryString95, querystring=queryString95, querycount=10, customerid=474} {id=482_queryString43, querystring=queryString43, querycount=5, customerid=482} {id=482_queryString64, querystring=queryString64, querycount=7, customerid=482} {id=483_queryString6, querystring=queryString6, querycount=2, customerid=483} {id=487_queryString86, querystring=queryString86, querycount=111, customerid=487} {id=494_queryString67, querystring=queryString67, querycount=1, customerid=494}

上面描述的功能只是示例功能,當然需要擴展以映射到特定的業務場景。 這可能涵蓋在網站上向客戶顯示搜索查詢云或進一步進行商務智能分析的業務場景。

Spring數據

還包括用于測試目的的Spring ElasticSearch來創建ESRepository以對總記錄進行計數并刪除All。
檢查服務以獲取詳細信息ElasticSearchRepoServiceImpl.java

產品總觀看次數:

@Document(indexName = "productviews", type = "productview", indexStoreType = "fs", shards = 1, replicas = 0, refreshInterval = "-1") public class ProductView {@Idprivate String id;@Versionprivate Long version;private Long productId;private int viewCount;......}public interface ProductViewElasticsearchRepository extends ElasticsearchCrudRepository<ProductView, String> { }long count = productViewElasticsearchRepository.count();

客戶熱門搜索查詢:

@Document(indexName = "topqueries", type = "custquery", indexStoreType = "fs", shards = 1, replicas = 0, refreshInterval = "-1") public class CustomerTopQuery {@Idprivate String id;@Versionprivate Long version;private Long customerId;private String queryString;private int count;......}public interface TopQueryElasticsearchRepository extends ElasticsearchCrudRepository<CustomerTopQuery, String> { }long count = topQueryElasticsearchRepository.count();

在以后的文章中,我們將介紹使用計劃的作業進一步分析數據,

  • 使用Oozie計劃針對配置單元分區進行協調的作業,并將作業捆綁以將數據索引到ElasticSearch。
  • 使用Pig來計算唯一客戶總數等

翻譯自: https://www.javacodegeeks.com/2014/05/elasticsearch-hadoop-indexing-product-views-count-and-customer-top-search-query-from-hadoop-to-elasticsearch.html

總結

以上是生活随笔為你收集整理的ElasticSearch-Hadoop:从Hadoop到ElasticSearch的产品视图计数索引和客户顶部搜索查询...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。