设置分词器:
vi elasticsearch.yml
index:
analysis:
analyzer:
pattern_analyzer:
type: custom
tokenizer: field_tokenizer
tokenizer:
field_tokenizer:
type: pattern
pattern: ",|:"
group: -1
重启 ES
创建索引,设置模式:
curl -XPUT '10.199.101.237:9200/test_1?pretty' -d'
{
"mappings": {
"crm_2": {
"properties": {
"id": { "type": "integer" },
"name": { "type": "string", "analyzer": "pattern_analyzer"}
}
}
}
}'
hive 创建表
CREATE EXTERNAL TABLE test_es222 (id INT, name STRING)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES('es.resource' = 'test_1/crm_2','es.index.auto.create' = 'true','es.nodes' = '10.199.101.237','es.port' = '9200');
输入数据:
实现功能