【问题标题】:Getting all values of 2 columns获取 2 列的所有值
【发布时间】:2019-03-27 06:38:59
【问题描述】:

我正在寻找合适的弹性搜索查询,

SELECT col1,col2 FROM myTable WHERE col1="value1" AND col2 = "value2"

例如: 这是我的地图,

{
    "mapping": {
        "doc": {
            "properties": {
                "book": {
                    "properties": {
                        "name": {
                            "type": "text"
                        },
                        "price": {
                            "type": "integer"
                        },
                        "booktype": {
                            "properties": {
                                "booktype": {
                                    "type": "text"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

我正在尝试编写一个查询,它将给我pricename,其中有booktype=Fiction

【问题讨论】:

    标签: django elasticsearch kibana elasticsearch-dsl elasticsearch-query


    【解决方案1】:

    试试这个:

    GET myTable/_search
    {
      "size": 1000,
      "_source": [
        "price",
        "name"
      ],
      "query": {
        "bool": {
          "must": [
            {
               "match": {
                 "booktype.booktype": "Fiction"
               }
            }
          ]
        }
      }
    }
    

    注意:您可能需要调整“大小”以满足您的需求。

    【讨论】:

    • 不使用外键,在我的情况下 col1 是 index.columns.col1 `` _source": { "index": { "columns": { "col1": "Product Manager" }, “open_positions”:2}```
    • “外键”是什么意思?
    • 如果我采用具有 inter、float 等的列(字符串除外),此查询效果很好。但即使在使相应的字段可搜索和可聚合之后,字符串也会失败
    • 用您想要匹配的示例文档和索引映射更新您的问题
    • 我已经更新了我的答案。由于tag 是嵌套的,因此您需要进行嵌套查询。
    猜你喜欢
    • 1970-01-01
    • 2021-10-29
    • 1970-01-01
    • 2021-09-18
    • 2022-01-06
    • 2021-12-13
    • 2014-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多