我有一个奇怪的场景。我有一个包含文本“6 Music Live Hour”的文档。 查询的第二部分 - span_term 匹配 "Hour" 时不会产生任何结果
{
"span_near" : {
"clauses" : [
{
"span_near" : {
"clauses" : [
{
"span_term" : {
"all_field" : {
"value" : "6",
"boost" : 1.0
}
}
},
{
"span_multi" : {
"match" : {
"wildcard" : {
"all_field" : {
"wildcard" : "M*c",
"boost" : 1.0
}
}
},
"boost" : 1.0
}
}
],
"slop" : 0,
"in_order" : true,
"boost" : 1.0
}
},
{
"span_term" : {
"all_field" : {
"value" : "Hour",
"boost" : 1.0
}
}
}
],
"slop" : 2147483647,
"in_order" : true,
"boost" : 1.0
}
}
但是,当我将其更改为通配符查询时,它会产生预期的结果。见下文。
{
"span_near" : {
"clauses" : [
{
"span_near" : {
"clauses" : [
{
"span_term" : {
"all_field" : {
"value" : "6",
"boost" : 1.0
}
}
},
{
"span_multi" : {
"match" : {
"wildcard" : {
"all_field" : {
"wildcard" : "M*c",
"boost" : 1.0
}
}
},
"boost" : 1.0
}
}
],
"slop" : 0,
"in_order" : true,
"boost" : 1.0
}
},
{
"span_multi" : {
"match" : {
"wildcard" : {
"all_field" : {
"wildcard" : "Hour",
"boost" : 1.0
}
}
},
"boost" : 1.0
}
}
],
"slop" : 2147483647,
"in_order" : true,
"boost" : 1.0
}
}
请任何人就我在第一个查询中做错了什么提出建议。
答案 0 :(得分:0)
将文本转换为小写,然后构建术语查询会产生预期的结果。