Ejemplo n.º 1
0
        /// <summary>
        /// Adds the facet queries.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="values">The values.</param>
        private void AddFacetQueries(
            Facets <ESDocument> param, string fieldName, IEnumerable <AttributeFilterValue> values, ISearchCriteria criteria)
        {
            if (values == null)
            {
                return;
            }

            var ffilter = new BoolFilter <ESDocument>();

            foreach (var f in criteria.CurrentFilters)
            {
                if (!f.Key.Equals(fieldName))
                {
                    var q = ElasticQueryHelper.CreateQuery(criteria, f);
                    ffilter.Must(ff => ff.Bool(bb => q));
                }
            }

            var facetFilter = new FacetFilter <ESDocument>();

            facetFilter.Bool(f => ffilter);

            //var filter = new FacetFilter<ESDocument>();
            //facetFilter.Terms(x => x.Values(values.Select(y => y.Value).ToArray()));
            //var filterFacet = new FilterFacet<ESDocument>();
            //filterFacet.FacetName(fieldName.ToLower()).FacetFilter(f => facetFilter);

            param.Terms(t => t.FacetName(fieldName.ToLower()).Field(fieldName.ToLower()).FacetFilter(ff => facetFilter));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the facet queries.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="criteria">Search criteria.</param>
        private void AddFacetQueries(Facets <ESDocument> param, string fieldName, ISearchCriteria criteria)
        {
            var ffilter = new BoolFilter <ESDocument>();

            foreach (var f in criteria.CurrentFilters)
            {
                if (!f.Key.Equals(fieldName))
                {
                    var q = ElasticQueryHelper.CreateQuery(criteria, f);
                    ffilter.Must(ff => ff.Bool(bb => q));
                }
            }

            var facetFilter = new FacetFilter <ESDocument>();

            facetFilter.Bool(f => ffilter);

            param.Terms(t => t.FacetName(fieldName.ToLower()).Field(fieldName.ToLower()).FacetFilter(ff => facetFilter));
        }
        /// <summary>
        /// Adds the facet queries.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="values">The values.</param>
        private void AddFacetQueries(
            Facets<ESDocument> param, string fieldName, IEnumerable<AttributeFilterValue> values, ISearchCriteria criteria)
        {
            if (values == null) return;

            var ffilter = new BoolFilter<ESDocument>();
            foreach (var f in criteria.CurrentFilters)
            {
                if (!f.Key.Equals(fieldName))
                {
                    var q = ElasticQueryHelper.CreateQuery(criteria, f);
                    ffilter.Must(ff => ff.Bool(bb=>q));
                }
            }

            var facetFilter = new FacetFilter<ESDocument>();
            facetFilter.Bool(f => ffilter);
            
            //var filter = new FacetFilter<ESDocument>();
            //facetFilter.Terms(x => x.Values(values.Select(y => y.Value).ToArray()));
            //var filterFacet = new FilterFacet<ESDocument>();
            //filterFacet.FacetName(fieldName.ToLower()).FacetFilter(f => facetFilter);

            param.Terms(t => t.FacetName(fieldName.ToLower()).Field(fieldName.ToLower()).FacetFilter(ff => facetFilter));
        }
        /// <summary>
        /// Adds the facet queries.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="criteria">Search criteria.</param>
        private void AddFacetQueries(Facets<ESDocument> param, string fieldName, ISearchCriteria criteria)
        {
            var ffilter = new BoolFilter<ESDocument>();
            foreach (var f in criteria.CurrentFilters)
            {
                if (!f.Key.Equals(fieldName))
                {
                    var q = ElasticQueryHelper.CreateQuery(criteria, f);
                    ffilter.Must(ff => ff.Bool(bb => q));
                }
            }

            var facetFilter = new FacetFilter<ESDocument>();
            facetFilter.Bool(f => ffilter);

            param.Terms(t => t.FacetName(fieldName.ToLower()).Field(fieldName.ToLower()).FacetFilter(ff => facetFilter));
        }