简体   繁体   中英

find documents with empty field / Attachment.Content in elastic search using Nest + C#

I am trying to search for documents with an empty field. These attempts do not work:

var searchResult1 = client.Search<Doc>(s => s
    .From(0)
    .Size(10)
    .Query(q => q
        .Match(m => m
        .Field(f => f.Attachment.Content)
        .Query("")
        )
    )
);

var searchResult2 = client.Search<Doc>(x => x
    .Query(query => query
        .Term(term => term
        .Field(new Field("Attachment.Content"))
        .Value("")
        )
    )
);

Please note that Attachment is of type Nest.Attachment.

did you already try Verbatim()

var searchResult2 = client.Search<Doc>(x => x
.Query(query => query
    .Term(t => t.Verbatim()
    .Field(f => f.x)
    .Value("")
    )
)
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM