我有以下查询
{
"query":{
"bool":{
"must":[
{
"match":{
"fieldOne":{
"query":"One two three four five six",
"minimum_should_match":2
}
}
},
{
"match":{
"fieldTwo":{
"query":"ten eleven twelve",
"minimum_should_match":2
}
}
}
]
}
}
}
我要添加的是fieldOne必须包含值“七”。我尝试如下添加另一个查询,该查询不返回任何结果
{
"match":{
"fieldOne":{
"query":"seven"
}
}
},
有什么想法吗?
修改:添加了映射和示例数据
映射如下:
{
"dataindex": {
"mappings": {
"data": {
"properties": {
"fieldOne": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fieldTwo": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fieldThree": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
使用两个文档采样数据
{
"_index": "dataindex",
"_type": "data",
"_id": "1",
"_score": 55.47536,
"_source": {
"id": "ae5836",
"fieldOne": "One two three four five six",
"fieldTwo": "ten eleven twelve",
"fieldThree": blah,
}
},
{
"_index": "dataindex",
"_type": "data",
"_id": "2",
"_score": 55.47536,
"_source": {
"id": "ae5836",
"fieldOne": "One two three four five six seven",
"fieldTwo": "ten eleven twelve",
"fieldThree": blah,
}
}
我将本文档用作概念证明,因此使用简单的数据
答案 0 :(得分:0)
想通了
{
"query":{
"bool":{
"must":[
{
"match":{
"fieldTwo":{
"query":"ten eleven twelve",
"minimum_should_match":2
}
}
},
{
"bool":{
"must":[
{
"match":{
"fieldOne":{
"query":"One two three four five six",
"minimum_should_match":3
}
}
},
{
"match":{
"fieldOne":{
"query":"seven",
"minimum_should_match":1
}
}
}
]
}
}
]
}
}
}