使用Solr和Key-Value Store Indexer對應HBase列字段查詢

1,添加solr和Key-Value Store Indexer組件服務

參考網址:

https://blog.csdn.net/sxhong/article/details/79217092
http://www.niuchaoqun.com/14543825447680.html
http://www.bubuko.com/infodetail-1920802.html
https://blog.csdn.net/qq236237606/article/details/79149276

重要:
https://blog.csdn.net/u010936936/article/details/78064148

alter 'v_news_227_info',{NAME =>'cf', REPLICATION_SCOPE =>1}

solrctl instancedir --generate $HOME/hbase-indexer/v_news_227_info


    <field name="HBase_Indexer_v_news_227_info_name"type="string"indexed="true"stored="true"/>
    HBase_Indexer_v_news_227_info_name
    
    solrctl instancedir --create v_news_227_info $HOME/hbase-indexer/v_news_227_info

solrctl collection --create v_news_227_info


    solrctl collection --create v_news_227_info -s 7 -r 3-m 21
    

    hbase-indexer add-indexer \
    --name HBase_Indexer_v_news_227_info_name \
    --indexer-conf $HOME/hbase-indexer/v_news_227_info/morphline-hbase-mapper.xml \
    --connection-param solr.zk=node-1:2181,node-2:2181,node-3:2181/solr \
    --connection-param solr.collection=v_news_227_info \
    --zookeeper node-1:2181,node-2:2181,node-3:2181

hbase-indexer add-indexer \
--name HBase_Indexer_v_news_227_info_name \
--indexer-conf $HOME/hbase-indexer/v_news_227_info/morphline-hbase-mapper.xml \
--connection-param solr.zk=node-2:2181/solr \
--connection-param solr.collection=v_news_227_info \
--zookeeper node-2:2181

hbase-indexer delete-indexer --name 'HBase_Indexer_v_news_227_info_name'

 hbase-indexer list-indexers
 
 disable 'v_news_227_info'
 alter 'v_news_227_info',{NAME =>'info1', REPLICATION_SCOPE =>1}
 enable 'v_news_227_info'
 
 solrctl instancedir --generate $HOME/hbase-indexer/newsinfo
 <field name="HBase_Indexer_newsinfo" type="string" indexed="true" stored="true"/>
 solrctl instancedir --create newsinfo $HOME/hbase-indexer/newsinfo
 //更新操作, 更新配置文件;
 solrctl instancedir --update newsinfo $HOME/hbase-indexer/newsinfo
 //更新collection;
 solrctl collection --reload newsinfo
 如果索引已經建立,已經有了索引數據,想要修改索引,則要先刪除索引數據集,清空數據集可以通過solr API來完成,也可以在命令行中完成,鍵入如下命令:
 solrctl collection --deletedocs newsinfo
 
 //solrctl collection --create newsinfo
 //solrctl collection --create newsinfo2
    solrctl collection --create newsinfo -s 7 -r 3 -m 21
    
<?xml version="1.0"?>
<indexer table="HBase_Indexer_newsinfo" mapper="com.ngdata.hbaseindexer.morphline.MorphlineResultToSolrMapper" read-row="never">
<param name="morphlineFile" value="morphlines.conf"/>
<param name="morphlineId" value="newsinfoMap"/>
</indexer>

HBase Indexer找不到morphlines.conf文件
/opt/cloudera/parcels/CDH/lib/hbase-solr/morphlines.conf
 所有問題是morphlines.conf找不到,在/opt/cloudera/parcels/CDH/lib/hbase-solr新建一個morphlines.conf文件,
 把morphline-hbase-mapper.xml的內容改一下
<paramname="morphlineFile"value="/opt/cloudera/parcels/CDH/lib/hbase-solr/morphlines.conf"></param>


hbase-indexer add-indexer \
--name news_info_indexer \
--indexer-conf $HOME/hbase-indexer/newsinfo/morphline-hbase-mapper.xml \
--connection-param solr.zk=node-2:2181/solr \
--connection-param solr.collection=newsinfo \
--zookeeper node-2:2181

Morphlines.conf
morphlines.conf

hbase-indexer delete-indexer --name 'news_info_indexer'

vi index_news_info.xml

hbase-indexer add-indexer --name newsinfotestindexer --indexer-conf $HOME/hbase-indexer/newsinfo/morphline-hbase-mapper.xml --connection-param solr.zk=node-2:2181/solr --connection-param solr.collection=newsinfo --zookeeper node-1:2181,node-2:2181,node-3:2181

**.***.***.**:8983

--morphline-file morphlines.conf

//這個是能用的,使用find / |grep morphlines.conf$命令
hadoop --config /etc/hadoop/conf jar /opt/cloudera/parcels/CDH/lib/hbase-solr/tools/hbase-indexer-mr-1.5-cdh5.11.2-job.jar --conf /etc/hbase/conf/hbase-site.xml --morphline-file /opt/cm-5.11.2/run/cloudera-scm-agent/process/1178-ks_indexer-HBASE_INDEXER/morphlines.conf --hbase-indexer-file /root/hbase-indexer/newsinfo/morphline-hbase-mapper.xml --zk-host node-2:2181/solr --collection newsinfo --reducers 0 --go-live

HBase_Indexer_newsinfo:*美團網* OR HBase_Indexer_newsinfo:*投資* 

HBase_Indexer_newsdt:*


使用solr做模糊查詢參考博客
https://cloud.tencent.com/developer/article/1078470
https://blog.csdn.net/yeyinglingfeng/article/details/79162544
https://www.cnblogs.com/xinfang520/p/7722363.html
分頁查詢:
https://blog.csdn.net/qq_20261343/article/details/50707860
https://blog.csdn.net/qq_37334135/article/details/76862508
https://www.cnblogs.com/pazsolr/p/5796920.html
https://blog.csdn.net/yelllowcong/article/details/78709435
https://blog.csdn.net/hu948162999/article/details/47727159
https://blog.csdn.net/HenryMrZ/article/details/79096848
http://www.cnblogs.com/seaspring/p/6428074.html

--------------------------------------------------------------------
詳細:
http://mxdxm.iteye.com/blog/2191342

HBase_Indexer_newsinfo:*美團網* OR HBase_Indexer_newsinfo:*投資* OR

Key-Value Store Indexer中的配置

Morphlines 文件

Key-Value Store Indexer(服務範圍)

SOLR_LOCATOR : {
  # Name of solr collection
  collection : newsinfo
  
  # ZooKeeper ensemble
  zkHost : "$ZK_HOST" 
}


morphlines : [
{
id : newsinfoMap
importCommands : ["org.kitesdk.**", "com.ngdata.**"]

commands : [                    
  {
    extractHBaseCells {
      mappings : [
        {
          inputColumn : "info1:Keywords"
          outputField : "HBase_Indexer_newsinfo" 
          type : string 
          source : value
        },
        {
            inputColumn :"info1:News_Dt"
            outputField :"HBase_Indexer_newsdt"
            type :string
            source : value
        },
        {
            inputColumn :"info1:Org_Name"
            outputField :"HBase_Indexer_Org_Name"
            type :string
            source : value
        }
      ]
    }
  }


  { logDebug { format : "output record: {}", args : ["@{}"] } }
]
}
]

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章