z3r0
z3r0

Reputation: 93

Elastic Search (5.0) filter context term query is not working

I have a filter query as shown below. I intend to filter on stripped-blocked-uri (exact match) which is not working,

{
    "query": {
        "bool": {
            "filter": [
                {
                    "term": {
                        "stripped-blocked-uri": "https://www.twitter.com:9090"
                    }
                },
                {
                    "term": {
                        "project-id": "1"
                    }
                },
                {
                    "term": {
                        "rule-id": "101"
                    }
                }
            ]
        }
    }
}

which is returning no hits.

My mapping is,

                    "stripped-blocked-uri": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },

Not sure what is going wrong here. Please help!

Upvotes: 0

Views: 108

Answers (1)

Joe - Check out my books
Joe - Check out my books

Reputation: 16933

Use the keyword field:

{
    "query": {
        "bool": {
            "filter": [
                {
                    "term": {
                        "stripped-blocked-uri.keyword": "https://www.twitter.com:9090"
                    }
                },
                {
                    "term": {
                        "project-id": "1"
                    }
                },
                {
                    "term": {
                        "rule-id": "101"
                    }
                }
            ]
        }
    }
}

Upvotes: 1

Related Questions