获取2列的所有值

Getting all values of 2 columns

我正在寻找合适的 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

试试这个:

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

注意:您可能需要调整 "size" 以满足您的需要。