Filter on empty string using ElasticSearch/Nest

Viewed 2480

This may be a silly question, but how do I filter on an empty string in ElasticSearch using Nest. Specifically, how do I recreate the following result:

curl http://localhost:9200/test/event/_search
{
    "filter" : { "term" : { "target" : "" }}
}

I've tried:

(f => f
    .Term("target", "")
);

which according to ElasticSearch and Nest filtering does not work is treated like a conditionless query and returns everything, while adding a .Strict() throws a DslException:

(f => f
    .Strict().Term("target", "")
);

I've also tried .Missing() and .Exists() to no avail.

The relevant section of my _mapping for reference:

{
    "event": {
        "dynamic": "false",
        "properties": {
            target": {
                "type": "string",
                "index": "not_analyzed",
                "store": true,
                "omit_norms": true,
                "index_options": "docs"
            }
        }
    }
}

Any pointers would be greatly appreciated.

2 Answers
Related