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": "中国你好,我爱你中国"
}
相关推荐
写代码的【黑咖啡】8 分钟前
大数据环境下如何维护模型文档:策略与实践
大数据
焦糖玛奇朵婷11 分钟前
扭蛋机小程序:线上扭蛋机模式发展新形势[特殊字符]
大数据·数据库·程序人生·小程序·软件需求
番茄撒旦在上19 分钟前
什么样的表适合做拉链表
大数据·数据仓库·hive
风若飞29 分钟前
Solr 8 ik-analyzer 中文分词 基本使用篇
中文分词·solr·lucene
Elastic 中国社区官方博客36 分钟前
在 Kibana 中可视化你的 Bosch Smart Home 数据
大数据·运维·elasticsearch·搜索引擎·信息可视化·全文检索·kibana
云老大TG:@yunlaoda3601 小时前
如何使用华为云国际站代理商的FunctionGraph进行事件驱动的应用开发?
大数据·数据库·华为云·云计算
yiersansiwu123d1 小时前
生成式AI重构内容生态,人机协同定义创作新范式
大数据·人工智能·重构
老蒋新思维1 小时前
创客匠人:从个人IP到知识变现,如何构建可持续的内容生态?
大数据·网络·人工智能·网络协议·tcp/ip·创客匠人·知识变现
Sui_Network1 小时前
Mysten Labs 与不丹王国政府的创新与技术部携手探索离线区块链
大数据·人工智能·web3·去中心化·区块链
互联科技报1 小时前
GEO优化工具、AI搜索引擎优化软件平台实测报告:四大平台深度体验与选型指南
大数据·人工智能·搜索引擎