当前位置:网站首页>ES mapping之keyword;term查詢添加keyword查詢;更改mapping keyword類型
ES mapping之keyword;term查詢添加keyword查詢;更改mapping keyword類型
2022-06-24 14:24:00 【loong_XL】
參考:https://blog.csdn.net/winterking3/article/details/108254346
https://blog.csdn.net/tclzsn7456/article/details/79956625
1、ES mapping之keyword
默認mapping結構一般是:
如果不設置mapping,ES默認把字符串設為text類型,並包含一個keyword子類型。
***這種結構保存字段會存兩份索引(個人理解),首先第一個type text這個會進行分詞建索引保存,再後面fields keyword會進行保存完整字符串附加
term查詢
1)直接term
(結構查不到,這是因為不加任何默認是text類型,這個字段保存是有分詞,比如電影分成了電和影兩個字保存)
{
"query": {
"bool": {
"must": [
{
"term": {
"channel": "電影"
}
}
]
}
}
}
索引這裏改成單字查詢可以查詢到
{
"query": {
"bool": {
"must": [
{
"term": {
"channel": "電"
}
}
]
}
}
}
##或
{
"query": {
"bool": {
"must": [
{
"term": {
"channel": "影"
}
}
]
}
}
}
或者用match查詢,這會進行分詞後再查詢
{
"query": {
"bool": {
"must": [
{
"match": {
"channel": "電影"
}
}
]
}
}
}
2)具體全匹配查詢term+keywod
這種查詢會依據mapping裏子類型keyword字段匹配,必須包含查詢字符串不分詞,相當於是查詢的不分詞前的原來字符串
{
"query": {
"bool": {
"must": [
{
"term": {
"channel.keyword": "電影"
}
}
]
}
}
}
3、更改mapping keyword類型
直接去掉text那一級,吧text直接改成keyword,這種皆可以直接進行term查詢進行不分詞全匹配了,不用再加keyword
#設置channel為keyword
PUT pigg_user
{
"mappings": {
"properties": {
"channel": {
"type": "keyword"
},
"age": {
"type": "short"
}
}
}
}
边栏推荐
- 09_ An efficient memory method
- How to solve the problem that iterative semi supervised training is difficult to implement in ASR training? RTC dev Meetup
- 在CVS中恢复到早期版本
- ssh-keygen 配置无需每次输入密码
- Development of B2B transaction collaborative management platform for kitchen and bathroom electrical appliance industry and optimization of enterprise inventory structure
- Redis interview questions
- [ansible problem processing] remote execution user environment variable loading problem
- Keras deep learning practice (11) -- visual neural network middle layer output
- Second, the examinee must see | consolidate the preferred question bank to help the examinee make the final dash
- Unity 热力图建立方法
猜你喜欢

IDEA 插件 Material Theme UI收费后的办法

【比特熊故事汇】6月MVP英雄故事|技术实践碰撞境界思维

ES mapping之keyword;term查询添加keyword查询;更改mapping keyword类型

作为一名开发者,对你影响最深的书籍是哪一本?

简谈企业Power BI CI /CD 实施框架

Research on MySQL composite index

MySQL log management, backup and recovery

Go language concurrency model mpg model

Linux 安装 CenOS7 MySQL - 8.0.26

Method of establishing unity thermodynamic diagram
随机推荐
How to solve the problem that iterative semi supervised training is difficult to implement in ASR training? RTC dev Meetup
box-sizing
Unity 热力图建立方法
PgSQL queries the largest or smallest data of a field in a group
R语言plotly可视化:使用plotly可视化数据划分后的训练集和测试集、使用不同的形状标签表征、训练集、测试集、以及数据集的分类标签(Display training and test split
鲲鹏arm服务器编译安装PaddlePaddle
Port conflict handling method for tongweb
Some basic database operations (providing the original database information)
C language ---18 function (user-defined function)
高薪程序员&面试题精讲系列115之Redis缓存如何实现?怎么发现热key?缓存时可能存在哪些问题?
Maximum path sum in binary tree [handle any subtree, then handle the whole tree]
Three efficient programming skills of go language
tongweb使用之端口冲突处理办法
IDEA 插件 Material Theme UI收费后的办法
The difference between V-IF and v-show
Return to new list
One article to get UDP and TCP high-frequency interview questions!
leetcode 139. Word Break 单词拆分(中等)
3环杀掉360安全卫士进程
MySQL title