Search code examples
elasticsearchnest

What is the replacement for FilteredQueryDescriptor?


Since FilteredQueryDescriptor has been removed due to upgrades in ES, do anyone have an idea on what was the replacement to this after the ES Upgrade. Currently, I am using Nest version 5.5.0? Are there any documentation that discusses the erplacement?


Solution

  • This query type has been removed.

    So, as official documentation stands, use filter option in bool query instead.

    client
        .Search<YourDocumentType>(s => s
            .Query(q => q
                .Bool(descriptor => descriptor
                    .Filter(f => f.Term("fieldId", "term")))));
    

    You can also rewrite this query using + operator. Please have a look into wonderful NEST documentation.

    Hope that helps.