Bool filter vs query using query_string in Lucene syntax


(SML) #1

Is there a performance difference between using these two queries, one using lucene syntax in query_string, and another writing out the filters directly?

{
    "query": {
        "bool": {
            "must_not": [
                {
                    "term": {
                        "team.cards.key.keyword": "giant"
                    }
                }
            ],
            "filter": [
                {
                    "query_string": {
                        "query": "gameMode.players.keyword:PvP AND team.cards.key.keyword:three-musketeers AND NOT team.cards.key.keyword:giant"
                    }
                }
            ]
        }
    }
}
{
    "query": {
        "bool": {
            "must_not": [
                {
                    "term": {
                        "team.cards.key.keyword": "giant"
                    }
                }
            ],
            "filter": [
                {
                    "term": {
                        "gameMode.players.keyword": "PvP"
                    }
                },
                {
                    "term": {
                        "team.cards.key.keyword": "three-musketeers"
                    }
                },
                {
                    "range": {
                        "timestamp": {
                            "gte": "now-7d/h",
                            "lte": "now/h",
                            "format": "epoch_millis"
                        }
                    }
                }
            ]
        }
    }
}

In dev environment, I can’t really see any performance differences but I am wondering if I will gain performance in production if I type it out in full as some of my searches appear to be a tad bit slow and I am wondering if this might be the cause.


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.