es自定义分词器支持数字字母分词,中文分词器jieba支持添加禁用词和扩展词典

自定义分析器,分词器

json 复制代码
PUT http://xxx.xxx.xxx.xxx:9200/test_index/
{
  "settings": {
    "analysis": {
      "analyzer": {
        "char_test_analyzer": {
          "tokenizer": "char_test_tokenizer",
          "filter": [
            "lowercase"
          ]
        }
      },
      "tokenizer": {
        "char_test_tokenizer": {
          "type": "ngram",
          "min_gram": 1,
          "max_gram": 2
        }
      }
    }
  },
  "mappings": {
    "test_zysf_index": {
      "properties": {
        "text": {
          "type": "text",
          "analyzer": "char_test_analyzer"
        }
      }
    }
  }
}

所有字段检索

json 复制代码
{
	"query": {
		"multi_match": {
			"query": "河北保定",
			"type": "cross_fields",
			"fields": ["*"],
			"operator": "AND"
    }
	}
}

高亮搜索

json 复制代码
{
  "highlight": {
    "fields": {
        "name": {},
        "content": {},
    },
    "pre_tags": ["<em>"],
    "post_tags": ["</em>"]
  }
}

分词测试

GET /test_index/_analyze

json 复制代码
{
  "analyzer": "char_test_analyzer",
  "text": "adfsjdsa12345646abADS"
}

jieba中文分词支持添加禁用词和扩展词库功能

创建索引:PUT http://xxxx:9200/test_index

json 复制代码
{
	"settings": {
		"analysis": {
			"filter": {
				"jieba_stopword": {
					"type": "stop",
					"stopwords_path": "/home/stopwords.txt"
				}
			},
			"tokenizer": {
	        	"jieba_tokenizer": {
		          	"type": "jieba_index",
		          	"user_dict": "/home/user.dict"
        		}
      		},
			"analyzer": {
				"my_jieba": {
					"filter": [
						"lowercase",
						"jieba_stopword"
					],
					"tokenizer": "jieba_tokenizer"
				}
			}
		}
	},
	"mappings": {
    	"test_index": {
      		"properties": {
        		"name": {
          			"type": "text",
					"index": true,
					"analyzer": "my_jieba",
					"similarity": "BM25"
        		}
      		}
    	}
  	}
}

分词测试:

GET http://xxxxxx:9200/test_index/_analyze

json 复制代码
{
  "analyzer": "my_jieba",
  "text": "中国你好,我爱你中国"
}
相关推荐
LplLpl116 小时前
AI 算法竞赛通关指南:基于深度学习的图像分类模型优化实战
大数据·人工智能·机器学习
庄小焱7 小时前
大数据治理域——数据资产管理示例
大数据·数据治理·大数据治理·数据治理实践
WordPress学习笔记10 小时前
专业建外贸网站公司推荐
大数据·前端·人工智能
Julian.zhou10 小时前
Anthropic破解长程任务难题:长期运行智能体的高效控制机制
大数据·人工智能
白日做梦Q12 小时前
Navicat for MySQL 详细使用指南:命令行操作与界面操作双视角全解析
大数据·mysql·adb·数据库开发
AI_567813 小时前
AI知识库如何重塑服务体验
大数据·人工智能
你好~每一天14 小时前
从传统行业到AI入门:我的CAIE Level I学习体验与思考
大数据·数据结构·人工智能·学习·jupyter·idea
G皮T14 小时前
【Elasticsearch】索引别名 aliases
大数据·elasticsearch·搜索引擎·es·索引·索引别名·aliases
wyiyiyi14 小时前
【数据结构+算法】非递归遍历二叉树的理解
大数据·数据结构·笔记·算法·leetcode·数据分析
爱跑步的程序员~14 小时前
Elasticsearch倒排索引
java·大数据·elasticsearch·搜索引擎·全文检索