Don*_* V. 4 search elasticsearch
我有一个像这样的共同术语查询.
{
"query" : {
"common" : {
"DocumentData.OCR_Text" : {
"query" : "block 310 luis",
"cutoff_frequency" : 0.001
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想搜索2个或更多字段,但这给了我一个错误.
{
"query" : {
"common" : {
"Grantors" : {
"query" : "block 310 luis",
"cutoff_frequency" : 0.001
},
"DocumentData.OCR_Text" : {
"query" : "block 310 luis",
"cutoff_frequency" : 0.001
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
嵌套:ElasticsearchParseException [预期字段名称但得到START_OBJECT"DocumentData.OCR_Text"];
你会怎么做?
您应该将其包装在Bool查询中
{
"query": {
"bool": {
"should": [
{
"common": {
"Grantors": {
"query": "block 310 luis",
"cutoff_frequency": 0.001
}
}
},
{
"common": {
"DocumentData.OCR_Text": {
"query": "block 310 luis",
"cutoff_frequency": 0.001
}
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)