获取2列的所有值

时间:2019-03-27 06:39:00

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

我正在寻找适合的Elasticsearch查询,

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

1 个答案:

答案 0 :(得分:0)

尝试一下:

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

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