Elastic search Filter tags

It seems Elastic search filter values returns maximum of 10 values, but the normal litium search returns filter values as 11 for Brands.

image

Litium version: 7.5.0

To extend the filters to 40 i have done like this:

In FilterAggregatorDecorator.cs i added the constant _numberOfFilters on 6 places:
(Im not sure you need them on all those places, but it works.

 AggregationContainerDescriptor<ProductDocument> BuildFilterAggregation(AggregationContainerDescriptor<ProductDocument> container, string fieldName)
                    {
                        return container
                            .Nested(fieldName, nestedPerField => nestedPerField
                                .Path(x => x.Tags)
                                .Aggregations(fieldAggregation => fieldAggregation
                                    .Filter("filter", fieldFilter => fieldFilter
                                        .Filter(filter => filter
                                            .Term(filterTerm => filterTerm
                                                .Field(field => field.Tags[0].Key)
                                                .Value(fieldName)
                                            )
                                        )
                                        .Aggregations(tags => tags
                                            .Terms("tags", termSelector => termSelector
                                                .Size(_numberOfFilters)
                                                .Field(field => field.Tags[0].Key)
                                                .Aggregations(subAggregation => subAggregation
                                                    .Terms("tag", tag => tag
                                                        .Size(_numberOfFilters)
                                                        .Field(x => x.Tags[0].Value)
                                                    )
                                                ).Size(_numberOfFilters)
                                            )
                                        )
                                    )
                                )
                            );
                    }


AggregationContainerDescriptor<ProductDocument> BuildFieldAggregation(AggregationContainerDescriptor<ProductDocument> selector, IEnumerable<string> fieldNames)
                {
                    return selector
                        .Nested("$all-tags", filterContainer => filterContainer
                            .Path(x => x.Tags)
                            .Aggregations(a => a
                                .Filter("filter", filterSelector => filterSelector
                                    .Filter(ff => ff
                                        .Bool(bq => bq
                                            .Must(m => m
                                                .Terms(t => t
                                                    .Field(x => x.Tags[0].Key)
                                                    .Terms(fieldNames)
                                                )
                                            )
                                        )
                                    )
                                    .Aggregations(termAgg => termAgg
                                        .Terms("tags", termSelector => termSelector
                                            .Size(_numberOfFilters)
                                            .Field(x => x.Tags[0].Key)
                                            .Aggregations(subAggregation => subAggregation
                                                .Terms("tag", valueSelector => valueSelector
                                                    .Size(_numberOfFilters)
                                                    .Field(x => x.Tags[0].Value)
                                                )
                                            ).Size(_numberOfFilters)
                                        )
                                    )
                                )
                            )
                        );
                }
1 Like

Thanks @Ericsj11 . It works.

This has also been fixed in the Accelerator package since 7.5.0, https://docs.litium.com/support/bugs/bug_details?id=52037

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