PUT http://localhost:9200/lrc_blog/_mapping
//请求体
{
"properties": {
"title": {
"type": "text",
"fielddata": true
}
}
}
post http://localhost:9200/索引名/_search
//请求体
{
"query": {
"match": {
"title": "科技"
}
}
}
全部数据
检索结果数据
post http://localhost:9200/索引名/_search
//请求体
{
"query": {
"match": {
"title": "科技"
}
},
"_source": ["title", "content"]
}
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"match": {
"title": "科技"
}
},
"_source": [
"title",
"content"
],
"sort": [
{
"title": {
"order": "desc"
}
}
]
}
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"match": {
"title": "科技"
}
},
"_source": [
"title",
"content"
],
"sort": [
{
"title": {
"order": "desc"
}
}
],
"from": 1,
"size": 2
}
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "捉着"
}
},
{
"match": {
"content": "关于庙堂权争与刀剑交错的江湖"
}
}
]
}
},
"_source": [
"title",
"content"
],
"sort": [
{
"title": {
"order": "asc"
}
}
]
}
全部数据
检索结果
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"bool": {
"should": [
{
"match": {
"title": "捉着"
}
},
{
"match": {
"content": "关于庙堂权争与刀剑交错的江湖"
}
}
]
}
},
"_source": [
"title",
"content"
],
"sort": [
{
"title": {
"order": "asc"
}
}
]
}
全部数据
检索结果
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"bool": {
"must_not": [
{
"match": {
"title": "科技兴国"
}
}
],
"must": [
{
"match": {
"content": "关于庙堂权争与刀剑交错的江湖"
}
}
]
}
},
"_source": [
"title",
"content"
],
"sort": [
{
"title": {
"order": "asc"
}
}
]
}
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"bool": {
"must_not": [
{
"match": {
"title": "科技兴国"
}
}
],
"must": [
{
"match": {
"content": "关于庙堂权争与刀剑交错的江湖"
}
}
],
"filter": {
"range": {
"age": {
"gte": 30,
"lte": 60
}
}
}
}
},
"_source": [
"title",
"content",
"age"
],
"sort": [
{
"title": {
"order": "asc"
}
}
]
}
全部数据
检索数据
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"match": {
"tags": "技术 文章"
}
},
"_source": [
"title",
"content",
"age",
"tags"
]
}
查询term:如果字段是text类型内部自动进行分词检索,keyword类型则是精确查询整个文本需匹配一致
post http://localhost:9200/lrc_blog3/_search
//请求体1
{
"query": {
"term": {
"name": "懂"
}
}
}
//请求体2
{
"query": {
"term": {
"name": "懂法守法所发生的 name 5"
}
}
//请求体3
{
"query": {
"term": {
"desc": "懂"
}
}
}
//请求体4
{
"query": {
"term": {
"desc": "懂法守法所发生的 desc 5"
}
}
}
索引结构
索引全部数据
检索结果1-keyword-仅百分百匹配
检索结果2-keyword-仅百分百匹配
检索结果3-text-支持单字符
检索结果4-text-不支持百分百匹配
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"match": {
"content": "江湖 刀剑"
}
},
"highlight": {
"fields": {
"content": {}
}
}
}
post http://localhost:9200/lrc_blog/_search
//请求体
{
"query": {
"match": {
"content": "江湖 刀剑"
}
},
"highlight": {
"pre_tags": "<span style='color:red'>",
"post_tags": "</span>",
"fields": {
"content":{}
}
}
}
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/weixin_39651356/article/details/124533041
内容来源于网络,如有侵权,请联系作者删除!