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": "中国你好,我爱你中国"
}
相关推荐
heimeiyingwang12 小时前
从 0 到 1:企业 AI 战略规划与落地路线图
大数据·人工智能
海兰12 小时前
Elasticsearch 9.3.0 日志数据源配置
大数据·elasticsearch·jenkins
之歆12 小时前
Hadoop MapReduce 详解
大数据·hadoop·mapreduce
W1333090890712 小时前
2026 大专大数据与会计专业考证书门槛低的有哪些?
大数据
周杰伦fans12 小时前
Android Studio Git 管理最佳实践
git·elasticsearch·android studio
geneculture12 小时前
智慧系统工程实践:从人机互助至人机协同
大数据·人工智能·机器学习·知识图谱·融智学的重要应用·哲学与科学统一性·融智时代(杂志)
是做服装的同学13 小时前
服装企业系统ERP是什么?其主要功能和优势有哪些?
大数据·经验分享·其他
AI周红伟14 小时前
周红伟:企业大模型微调和部署, DeepSeek-OCR v2技术原理和架构,部署案例实操。RAG+Agent智能体构建
大数据·人工智能·大模型·ocr·智能体·seedance
零售ERP菜鸟14 小时前
数据驱动:从经验主义的“后视镜”到科学决策的“导航仪”
大数据·人工智能·职场和发展·创业创新·学习方法·业界资讯