YousefED / ElasticUI

AngularJS directives for Elasticsearch
http://www.elasticui.com
Other
526 stars 134 forks source link

Can't filter by the "document type" #66

Open AbdiSaeed opened 8 years ago

AbdiSaeed commented 8 years ago

Hi, I am fairly new to AngularJS and Elastic so I would appreciate any help on this.

I am trying to use the euiaggregation directive to filter by the "document type" like so:

                <ul class="nav nav-list" eui-aggregation="ejs.TermsAggregation(agg_name).field('_type').size(2)">
                    <li ng-repeat="bucket in aggResult.buckets">
                        <label eui-filter="ejs.TermsFilter(field, bucket.key)">
                            <span ng-if="!filter.enabled"><a href="" ng-click="filter.enabled=true">{{bucket.key}} <span class="muted">({{bucket.doc_count}})</span></a></span>
                            <span ng-if="filter.enabled">{{bucket.key}} <a href="" ng-click="filter.enabled=false" class="facet-remove">x</a></span>
                        </label>
                    </li>
                </ul>

It works as far as showing a list of document types but when I click on one of the type links, the list of types disappear and the initial data displayed also disappears.

However, using the eui-singleselect directive (which I understand to be equivalent to above) seems to work when used like this:

<eui-singleselect field="'_type'" size="9"></eui-singleselect>

It shows the list and when I click on one of the types it filters the list. Only problem I got with it is that I want the html output to be different hence why I was using the longer version.

Also related separate question: when I click on one of the filter links, how can I force the list entire list remains (currently list disappears apart from the active filter link)

Thanks

manateeit commented 8 years ago

I made the exact same mistake and spent hours trying to figure it out. Not sure if you got an answer to your problem, but I will post here in any else is also having this same issue. You have to change what I have highlighted in field to the '_type'.

                <ul class="nav nav-list" eui-aggregation="ejs.TermsAggregation(agg_name).field('_type').size(2)">
                    <li ng-repeat="bucket in aggResult.buckets">
                        <label eui-filter="ejs.TermsFilter(**field**, bucket.key)">
                            <span ng-if="!filter.enabled"><a href="" ng-click="filter.enabled=true">{{bucket.key}} <span class="muted">({{bucket.doc_count}})</span></a></span>
                            <span ng-if="filter.enabled">{{bucket.key}} <a href="" ng-click="filter.enabled=false" class="facet-remove">x</a></span>
                        </label>
                    </li>
                </ul>