Javascript Elasticsearch相当于x=1和(y=2或y=3)
我正在寻找与以下伪代码等效的代码:Javascript Elasticsearch相当于x=1和(y=2或y=3),javascript,
elasticsearch,Javascript,
elasticsearch,我正在寻找与以下伪代码等效的代码: SELECT id, age // works FROM students // works WHERE firstname = 'John' // works AND gender = 'm' // works
SELECT id, age // works
FROM students // works
WHERE firstname = 'John' // works
AND gender = 'm' // works
AND (lastname = 'Doe' OR lastname = 'Wayne') // no idea
我当前的代码:
{
// ...
query: {
bool: {
must: [
{ match: { firstname: 'John' }},
{ match: { gender: 'm' }},
]
}
}
}
我正在与或作斗争
有什么想法吗
提前谢谢 试试这个:
{
// ...
query: {
bool: {
must: [
{ match: { firstname: 'John' }},
{ match: { gender: 'm' }},
{
bool: {
minimum_should_match: 1,
should: [
{ match: { lastname: 'Doe' }},
{ match: { lastname: 'Wayne' }}
]
}
}
]
}
}
}
试试这个:
{
// ...
query: {
bool: {
must: [
{ match: { firstname: 'John' }},
{ match: { gender: 'm' }},
{
bool: {
minimum_should_match: 1,
should: [
{ match: { lastname: 'Doe' }},
{ match: { lastname: 'Wayne' }}
]
}
}
]
}
}
}
尝试:
尝试:
看一看这个看一看这个我很惊讶这能起作用,因为匹配查询不支持正则表达式。我很惊讶这能起作用,因为匹配查询不支持正则表达式。