news-ai / tabulae

API for media list management
https://tabulae.newsai.org/
0 stars 0 forks source link

OR or AND return contacts on tags #434

Open AbhiAgarwal opened 7 years ago

AbhiAgarwal commented 7 years ago

AND:

{
    "query": {
        "bool": {
            "must": [{
                "term": {
                    "data.CreatedBy": 5749563331706880
                }
            }, {
                "match": {
                    "data.Tags": "Technology"
                }
            },{
                "match": {
                    "data.Tags": "TechCrunch"
                }
            },{
                "match": {
                    "data.Tags": "Google"
                }
            }]
        }
    },
    "size": 50,
    "from": 0
}

multiple match queries

AbhiAgarwal commented 7 years ago

OR:

doesn't work, but something similar should work:

{
    "query": {
        "bool": {
            "must": [{
                "term": {
                    "data.CreatedBy": 5749563331706880
                }
            }],
            "filter": [{
                "match": {
                    "data.Tags": "Mobile"
                }
            },{
                "match": {
                    "data.Tags": "TechCrunch"
                }
            }]
        }
    },
    "size": 50,
    "from": 0
}
AbhiAgarwal commented 7 years ago

filtered queries also work well:

purely these:

{
    "filtered": {
        "query": {
            "match_all": {}
        },
        "filter": {
            "bool": {
                "should": [
                    {
                        "term": {
                            "name": "xyz"
                        }
                    },
                    {
                        "term": {
                            "description": "xyz"
                        }
                    }
                ]
            }
        }
    }
}`