分词查询 忽略大小写
PUT es_test?pretty
{
"settings": {
"index": {
"analysis": {
"analyzer": { //自定义搜索器
"ik_lower_case_analyzer": {
"tokenizer": "ik_max_word",
"type": "custom",
"filter": [
"lowercase"
]
}
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"Title": { //字段名
"type": "text",
"analyzer": "ik_lower_case_analyzer", //自定义的搜索器
"search_analyzer": "ik_lower_case_analyzer"
}
}
}
}
}
GET /mst_rights_dev/_search
{
"_source": ["Title","Content"],
"query": {
"bool": {
"must": [
{
"match": {
"Category": 1
}
},
{
"bool": {
"should": [
{
"match": {
"Title": "abc"
}
}
]
}
}
]
}
}
}
模糊查询 忽略大小写
PUT es_test?pretty
{
"settings": {
"analysis": {
"analyzer": {
"caseSensitive": {
"tokenizer": "keyword",
"type": "custom",
"filter": [
"lowercase"
]
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"Title": {
"type": "text",
"analyzer": "caseSensitive",
"search_analyzer": "caseSensitive"
}
}
}
}
}
给索引增加新的字段
PUT mst_rights_dev/_mapping/_doc
{
"properties": {
"Amount": {
"type": "long"
}
}
}