读书笔记:从Lucene到Elasticsearch:全文检索实战

从Lucene到Elasticsearch:全文检索实战

当前的笔记只介绍 Elasticsearch 的搜索部分。

文章中的搜索都是在 kibanaDev tools 进行查询的。

准备工作

需要安装 Elasticsearchkibanaelasticsearch-analysis-ik

具体的安装方式,这里就不再阐述了。(安装完,记得重启 Elasticsearch

重启完成后,打开 kibanaDev tools,输入下面的DSL代码,并运行:

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
PUT books
{
"settings": {
"number_of_replicas": 1,
"number_of_shards": 3
},
"mappings": {
"IT": {
"properties": {
"id": {
"type": "long"
},
"title": {
"type": "text",
"analyzer": "ik_max_word"
},
"language": {
"type": "keyword"
},
"author": {
"type": "keyword"
},
"price": {
"type": "double"
},
"year": {
"type": "date",
"format": "yyyy-MM-dd"
},
"description": {
"type": "text",
"analyzer": "ik_max_word"
}
}
}
}
}
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×