我有以下查询:
{
"query" : {
"bool" : {
"must" : [
{
"query_string" : {
"query" : "dog cat",
"analyzer" : "standard",
"default_operator" : "AND",
"fields" : ["title", "content"]
}
},
{
"range" : {
"dateCreate" : {
"gte" : "2018-07-01T00:00:00+0200",
"lte" : "2018-07-31T23:59:59+0200"
}
}
},
{
"regexp" : {
"articleIds" : {
"value" : ".*?(2561|30|540).*?",
"boost" : 1
}
}
}
]
}
}
}
字段title,content和articleIds的类型为text,dateCreate的类型为date。 articleIds字段包含一些ID(以逗号分隔)。
好,现在发生了什么?我执行查询得到两个结果:两个文档的标题或内容中都包含单词“ dog”和“ cat”。到目前为止是正确的。
但是第二个结果的articleIds字段中的数字为3507,与我的查询不匹配。似乎正则表达式被忽略了,因为标题和内容已经匹配。怎么了?
这是不符合我的查询要求但符合的文档:
{
"_index" : "example",
"_type" : "doc",
"_id" : "3007780",
"_score" : 21.223656,
"_source" : {
"dateCreate" : "2018-07-13T16:54:00+0200",
"title" : "",
"content" : "Its raining cats and dogs.",
"articleIds" : "3507"
}
}
我期望该文档不应该出现在结果中,因为它包含3507,这不是我查询的一部分...