0

我有一个查询:

{
    "query": {
        "bool" : {
            "must": [
                { "match": { "tags": "htc" } },
                { "match": { "votype" : 1} },
                { "match": { "subtype": 1 } },
                { "match": { "deleted": 0 } },
                { "match": { "build_status": 4 } },
                { "match": { "publish": 1 } }
            ]
        }
    },

    "sort": [
        { "created": "desc" }
    ],

    "size": 30,
    "from": 0
}

我想放入值的值列表中

{ "match": { "votype": [1 or 2 or 3] } }

SQL 类比:

SELECT * FROM tablename WHERE type IN(1, 2);

但不知道怎么做

不工作:

{ "match": { "votype": [1,3] } },
{ "match": { "votype": "1 2" } },
{ "match": { "votype": "1OR2" } }
4

2 回答 2

1

这行得通吗?

{ "match": { "votype": "1 2 3" } }
于 2013-02-19T16:33:53.123 回答
1

我的解决方案

{
    "query": {
        "bool" : {
            "must": [
                { "terms" : { "tags": ["htc"], "minimum_match": 1 } },
                { "terms" : { "votype" : [1,2], "minimum_match": 1 } },
                { "terms" : { "deleted": [0], "minimum_match": 1 } },
                { "terms" : { "build_status": [4], "minimum_match": 1 } },
                { "terms" : { "publish": [1], "minimum_match": 1 } }
            ]

        }
    },

    "sort": [
        { "created": "desc" }
    ],

    "size": 30,
    "from": 0
}
于 2013-02-20T13:32:40.640 回答