您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch为索引指定默认分析器
发布时间:2021-09-10 23:10:44编辑:雪饮阅读()
在elasticSearch中索引的分析器一般默认的是standard分析器。
那么这个分析器也是可以被修改的。
请求正文:
{
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "simple"
}
}
}
}
}
响应正文:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "my-index-000001"
}
可以看到这里将索引的默认分析器配置为simple分析器了。
那么我们知道simple分析器是拆分为所有术语都是小写的。
那么有如下情况,就是说我先建立一个测试数据:
请求正文:
{
"title":"quick brown fox BOX", "description":"ICSE", "street":"West End",
"state":"UP", "zip":"250002", "location":[28.9926174, 77.692485], "fees":3500,
"tags":["fully computerized"], "rating":"4.5"
}
响应正文:
{
"_index": "my-index-000001",
"_type": "_doc",
"_id": "4",
"_version": 2,
"result": "updated",
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 1,
"_primary_term": 1
}
这里建立的测试数据中title中包含大写的”BOX”,那么此时我用小写的box进行match查询
请求正文:
{
"query": {
"match": {
"title": {
"query": "box"
}
}
}
}
响应正文:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 0.6548753,
"hits": [
{
"_index": "my-index-000001",
"_type": "_doc",
"_id": "4",
"_score": 0.6548753,
"_source": {
"title": "quick brown fox BOX",
"description": "ICSE",
"street": "West End",
"state": "UP",
"zip": "250002",
"location": [
28.9926174,
77.692485
],
"fees": 3500,
"tags": [
"fully computerized"
],
"rating": "4.5"
}
}
]
}
}
可见这里是能查询到的。那么这里查询的字串换成BOX:
请求正文:
{
"query": {
"match": {
"title": {
"query": "BOX"
}
}
}
}
响应正文:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 0.2876821,
"hits": [
{
"_index": "my-index-000001",
"_type": "_doc",
"_id": "4",
"_score": 0.2876821,
"_source": {
"title": "quick brown fox BOX",
"description": "ICSE",
"street": "West End",
"state": "UP",
"zip": "250002",
"location": [
28.9926174,
77.692485
],
"fees": 3500,
"tags": [
"fully computerized"
],
"rating": "4.5"
}
}
]
}
}
同样也是能查到的,那么就我个人理解这里指定默认分析器,是同时指定了字段的默认分析器和search查询的默认分析器的。
关键字词:elasticSearch,索引,指定,默认分析器
相关文章
- elasticSearch映射参数boost
- elasticSearch创建指定字段的搜索分析器(空白分析仪与
- elasticSearch为查询指定搜索分析器(stop分析器)
- elasticSearch创建指定字段分析器
- elasticSearch创建custom分析器char_filter,tokenizer
- elasticSearch创建custom分析器搭载html条带字符过滤
- elasticSearch内置分析器(停用词的使用)
- elasticSearch索引中创建自定义分析器(custom)及按分
- elasticSearch测试分析仪-标准标记器与ASCII码折叠标
- elasticSearch测试分析仪