Elasticsearch filters

I will receive the filter inputs from the front-end some may be null or empty but in the elasticsearch query filter all the field should be present . How to get response even the inputs are empty for some filters ?

{
    "query": {
        "bool": {
            "must": {
                "match": {
                    "Abstract": "cancer"
                }
            },
            "filter": [
                {
                    "term": {
                        "Publication Type": "Review"
                    }
                },
                {
                    "range": {
                        "Date Completed": {
                            "gte": "1800",
                            "lte": "2017",
                            "format": "yyyy"
                        }
                    }
                }
            ]
        }
    }
}

Then you need to have some defaults that are passed in by the code.
Either that or use a search template - Search Template | Elasticsearch Guide [6.5] | Elastic

sorry Im new to elasticsearch could you elaborate

Hello,
As per my knowledge,
when inputs are coming from frontend ,
i.you need to keep validations for those fields and inform the user that inputs must not be null.
or
ii.replace null or empty with default value.

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