【问题标题】:How to add multiple fields to a common terms query in ElasticSearch?如何向 ElasticSearch 中的常用术语查询添加多个字段?
【发布时间】:2015-02-18 19:16:40
【问题描述】:

我有一个像这样的常用术语查询。

{
    "query" : {
        "common" : {
            "DocumentData.OCR_Text" : {
                "query" : "block 310 luis",
                "cutoff_frequency" : 0.001
            }
        }
    }
}

我想搜索 2 个或更多字段,但这给了我一个错误。

{
    "query" : {
        "common" : {
            "Grantors" : {
                    "query" : "block 310 luis",
                    "cutoff_frequency" : 0.001
                },
            "DocumentData.OCR_Text" : {
                "query" : "block 310 luis",
                "cutoff_frequency" : 0.001
            }
        }
    }
}

nested: ElasticsearchParseException[预期的字段名称,但得到 START_OBJECT "DocumentData.OCR_Text"];

你会怎么做?

【问题讨论】:

    标签: search elasticsearch


    【解决方案1】:

    你应该把它包装在Bool Query

    {
        "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
                            }
                        }
                    }
                ]
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2022-01-03
      • 1970-01-01
      • 2021-05-03
      • 2016-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-18
      相关资源
      最近更新 更多