【发布时间】:2021-02-23 17:34:45
【问题描述】:
下面2个有区别吗?
GET books/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"description": {
"query": "cat dog"
}
}
}
]
}
}
}
和
GET books/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"description": {
"query": "cat"
}
}
},
{
"match": {
"description": {
"query": "dog"
}
}
}
]
}
}
}
从结果来看,我认为它们是相同的。我使用的索引文档如下
POST books/_bulk
{"index":{}}
{ "title": "Dogs", "description": "A fox jump over the lazy dog" }
{"index":{}}
{ "title": "Cats", "description": "Garfield the sleepy cat" }
{"index":{}}
{ "title": "Sleepy", "description": "Rest is important" }
{"index":{}}
{ "title": "Rich", "description": "Money is never enough" }
{"index":{}}
{ "title": "Pets", "description": "Dog and cat are friends" }
{"index":{}}
{ "title": "Character", "description": "Are you really a dog person?" }
映射是默认映射
{
"books" : {
"mappings" : {
"properties" : {
"description" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"title" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
【问题讨论】:
-
你能分享你的索引映射吗?
-
我没有显式设置任何映射,它是默认的动态设置映射。
-
当然,这样您的文本字段将使用标准分析器,我将重现您的问题,并添加示例,同时请仔细阅读我的答案,这也会使事情变得清晰
标签: elasticsearch