使用软件版本:elasticsearch-2.2.0
1. setting:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
curl -XPOST 'http://localhost:9200/data' -d '{
"settings" : {
"analysis" : {
"analyzer" : {
"comma" : {
"type" : "pattern" ,
"pattern" : ","
}
}
}
}
}
} ' |
return:
1
|
{ "acknowledged" : true }
|
2. view index:
1
|
curl -XGET 'http://localhost:9200/data'
|
return:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
{ "data" : {
"aliases" : {},
"mappings" : {},
"settings" : {
"index" : {
"creation_date" : "1456931889151" ,
"analysis" : {
"analyzer" : {
"comma" : {
"pattern" : "," ,
"type" : "pattern"
}
}
},
"number_of_shards" : "5" ,
"number_of_replicas" : "1" ,
"uuid" : "aXyFMRzKQ0m_Ex8N2yJeSA" ,
"version" : {
"created" : "2020099"
}
}
},
"warmers" : {}
}
} |
3. mapping:
1
2
3
4
5
6
7
|
curl -XPOST 'http://localhost:9200/data/_mapping/record' -d '{
"properties" : {
"id" : { "type" : "string" , "index" : "not_analyzed" },
"number" : { "type" : "string" , "analyzer" : "comma" , "search_analyzer" : "comma" }
}
} ' |
return:
1
|
{ "acknowledged" : true }
|
4. view index:
1
|
curl -XGET 'http://localhost:9200/data'
|
return:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
{ "data" : {
"aliases" : {},
"mappings" : {
"record" : {
"properties" : {
"id" : {
"type" : "string" ,
"index" : "not_analyzed"
},
"number" : {
"type" : "string" ,
"analyzer" : "comma"
}
}
}
},
"settings" : {
"index" : {
"creation_date" : "1456972030705" ,
"analysis" : {
"analyzer" : {
"comma" : {
"pattern" : "," ,
"type" : "pattern"
}
}
},
"number_of_shards" : "5" ,
"number_of_replicas" : "1" ,
"uuid" : "A9Z76U9DR0OBqn29smtq8w" ,
"version" : {
"created" : "2020099"
}
}
},
"warmers" : {}
}
} |
5. verify analyze:
1
|
curl -GET 'http://127.0.0.1:9200/data/_analyze?analyzer=comma&text=2,3,4,5,100-100'
|
return:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
{ "tokens" : [
{
"token" : "2" ,
"start_offset" : 0,
"end_offset" : 1,
"type" : "word" ,
"position" : 0
},
{
"token" : "3" ,
"start_offset" : 2,
"end_offset" : 3,
"type" : "word" ,
"position" : 101
},
{
"token" : "4" ,
"start_offset" : 4,
"end_offset" : 5,
"type" : "word" ,
"position" : 202
},
{
"token" : "5" ,
"start_offset" : 6,
"end_offset" : 7,
"type" : "word" ,
"position" : 303
},
{
"token" : "100-100" ,
"start_offset" : 8,
"end_offset" : 15,
"type" : "word" ,
"position" : 404
}
]
} |
6. post data:
1
2
3
4
5
|
curl -PUT 'http://localhost:9200/data/record' -d '{
"id" : "001CV" ,
"number" : "2,3,4,5,100-100,1010"
} ' |
return:
1
2
3
4
5
6
7
8
9
10
11
12
|
{ "_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3kt-GiEDWd2i_MREb" ,
"_version" : 1,
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : true
} |
7. post data:
1
2
3
4
5
|
curl -PUT 'http://localhost:9200/data/record' -d '{
"id" : "002CV" ,
"number" : "9999,8888"
} ' |
return:
1
2
3
4
5
6
7
8
9
10
11
12
|
{ "_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3k7vIiEDWd2i_MREc" ,
"_version" : 1,
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : true
} |
8. post data:
1
2
3
4
5
|
curl -PUT 'http://localhost:9200/data/record' -d '{
"id" : "002CV" ,
"number" : "2,8888"
} ' |
return:
1
2
3
4
5
6
7
8
9
10
11
12
|
{ "_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3mCGMiEDWd2i_MREh" ,
"_version" : 1,
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : true
} |
9. search data:
1
|
curl -XGET 'http://localhost:9200/data/record/_search?q=number:9999'
|
return:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{ "took" : 41,
"timed_out" : false ,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.19178301,
"hits" : [
{
"_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3k7vIiEDWd2i_MREc" ,
"_score" : 0.19178301,
"_source" : {
"id" : "002CV" ,
"number" : "9999,8888"
}
}
]
}
} |
10. search data:
1
|
curl -XGET 'http://localhost:9200/data/record/_search?q=number:2'
|
return:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
{ "took" : 2,
"timed_out" : false ,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 0.37158427,
"hits" : [
{
"_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3mCGMiEDWd2i_MREh" ,
"_score" : 0.37158427,
"_source" : {
"id" : "002CV" ,
"number" : "2,8888"
}
},
{
"_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3kt-GiEDWd2i_MREb" ,
"_score" : 0.22295055,
"_source" : {
"id" : "001CV" ,
"number" : "2,3,4,5,100-100,1010"
}
}
]
}
} |
11. search data:
1
|
curl -XGET 'http://localhost:9200/data/record/_search?q=number:8888,100-100'
|
return:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
{ "took" : 3,
"timed_out" : false ,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : 0.22097087,
"hits" : [
{
"_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3mCGMiEDWd2i_MREh" ,
"_score" : 0.22097087,
"_source" : {
"id" : "002CV" ,
"number" : "2,8888"
}
},
{
"_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3kt-GiEDWd2i_MREb" ,
"_score" : 0.13258252,
"_source" : {
"id" : "001CV" ,
"number" : "2,3,4,5,100-100,1010"
}
},
{
"_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3k7vIiEDWd2i_MREc" ,
"_score" : 0.028130025,
"_source" : {
"id" : "002CV" ,
"number" : "9999,8888"
}
}
]
}
} |
12. search data:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
curl -XPOST 'http://localhost:9200/data/record/_search' -d '{
"query" : {
"bool" : {
"must" : [
{
"term" : {
"number" : "2"
}
}
],
"must_not" : [
{
"term" : {
"number" : "8888"
}
}
]
}
}
}' |
return:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{ "took" : 3,
"timed_out" : false ,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.22295055,
"hits" : [
{
"_index" : "data" ,
"_type" : "record" ,
"_id" : "AVM3kt-GiEDWd2i_MREb" ,
"_score" : 0.22295055,
"_source" : {
"id" : "001CV" ,
"number" : "2,3,4,5,100-100,1010"
}
}
]
}
} |
相关推荐
elasticsearch-analysis-ik 是一个常用的中文分词器,在 Elasticsearch 中广泛应用于中文文本的分析和搜索。下面是 elasticsearch-analysis-ik 分词器的几个主要特点: 中文分词:elasticsearch-analysis-ik 是基于...
Elasticsearch电商平台中文分词词库
适用于elasticsearch7.17.11版本的分词器插件安装包
elasticsearch中文分词插件,解压至ES安装目录,如D:\works\elasticsearch-6.4.0\plugins\ik,注意,不用修改elasticsearch.yml,就可以直接使用了。
elasticsearch的ik中文分词器,安装好elasticsearch后还需安装中文分词器
如果直接使用Elasticsearch的朋友在处理中文... 这是因为使用了Elasticsearch中默认的标准分词器,这个分词器在处理中文的时候会把中文单词切分成一个一个的汉字,因此引入es之中文的分词器插件es-ik就能解决这个问题。
用于elasticsearch7.6.2配套的中文分词器,欢迎大家使用 下面是它的描述,用于elasticsearch7.6.2配套的中文分词器,
elasticsearch7.8.0版本的IK分词器
如果直接使用Elasticsearch的朋友在处理中文... 这是因为使用了Elasticsearch中默认的标准分词器,这个分词器在处理中文的时候会把中文单词切分成一个一个的汉字,因此引入es之中文的分词器插件es-ik就能解决这个问题。
elasticsearch-7.17.6及对应版本IK分词 适合人群:elasticsearch初学者 Elasticsearch 是位于 Elastic Stack 核心的分布式搜索和分析引擎。Logstash 和 Beats 有助于收集、聚合和丰富您的数据并将其存储在 Elastic...
适用于elasticsearch7.17.14版本的分词器插件安装包
IK中文分词器在Elasticsearch上的使用。原生IK中文分词是从文件系统中读取词典,es-ik本身可扩展成从不同的源读取词典。目前提供从sqlite3数据库中读取。es-ik-plugin-sqlite3使用方法: 1. 在elasticsearch.yml中...
适用于elasticsearch7.17.13版本的分词器插件安装包
Elasticsearch 7.6.2 已集成ik分词器 解压后运行bin目录下,elasticsearch.bat文件
自定义elasticsearch分词插件,在网上找了一个空格分词的实现,主要看思路,方便大家写自己的分词插件
也希望本文对使用 ElasticSearch 和 IK分词插件的开发者有所帮助。希望能少走点弯路。 本文包括前言、IK分词介绍、分词效果对比、自定义词典使用、索引设置和字段设置(Python 创建索引并导入数据)、查询测试...
elasticsearch-analysis-pinyin-7.4.0 es拼音分词器7.4.0
使用checkout tag: v5.1.2git checkout v5.1.2运行gradle buildPluginZip创建 directory ${path.home}/plugins/jieba复制zip 文件到分词插件cp build/distributions/elasticsearch-jieba-plugin-5.1.2.zip ${...
适用于elasticsearch7.17.10版本的分词器插件安装包
elasticsearch-7.0.0版本 ik中文分词器,编译好的文件,亲测成功,2.4.6版本的见在本人其他资源中寻找,免费下载,成功请给好评。