GithubHelp home page GithubHelp logo

Facet Filter about plainelastic.net HOT 4 CLOSED

yegoroff avatar yegoroff commented on August 29, 2024
Facet Filter

from plainelastic.net.

Comments (4)

Woland2k avatar Woland2k commented on August 29, 2024

I added FilterFacet which allows defining filter facets as described here: http://www.elasticsearch.org/guide/reference/api/search/facets/filter-facet.html

Here is a new class:
https://github.com/Woland2k/PlainElastic.Net/blob/master/src/PlainElastic.Net/Builders/Queries/Facets/FilterFacet.cs

Now need to allow bool queries inside filters.

from plainelastic.net.

Yegoroff avatar Yegoroff commented on August 29, 2024

Thanks for feedback and for providing FilterFacet builder - I'll add it to facets builders.

This issue with FacetFilter happened because I haven't finished facets building yet. ( actually only Terms facet supported )
Anyway I've fixed FacetFilter generation, so now you can use code like this to apply custom filtering to any facet:

     var json  = 
        new QueryBuilder<ESDocument>()
                .Facets(facet => facet
                    .Terms(t => t
                        .FacetName("brand")
                        .Field("brand")
                        .FacetFilter(f => f
                            .Range(r => r
                                .Field("price")
                                .IncludeLower(false)
                                .IncludeUpper(true)
                                .From("Lower")
                                .To("Upper"))
                        )
                    )
                ).BuildBeautified();

this will generate the following JSON:

{
    "facets": {
        "brand": {
            "terms": {
                "field": "brand"
            },
            "facet_filter": {
                "range": {
                    "price": {
                        "include_lower": false,
                        "include_upper": true,
                        "from": "Lower",
                        "to": "Upper"
                    }
                }
            }
        }
    }
}

from plainelastic.net.

Woland2k avatar Woland2k commented on August 29, 2024

Great, I did implement some more Facet filtering including BoolFilter and FilterFacet if you want to include into the main code.

from plainelastic.net.

Yegoroff avatar Yegoroff commented on August 29, 2024

Thanks, I've added FilterFacet JSON builder will look at BoolFIlter.

from plainelastic.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.