YousefED / ElasticUI

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

Setting up a filtered query #96

Closed thehybridtechnician closed 8 years ago

thehybridtechnician commented 8 years ago

I have been reading about optimizing search queries. https://www.elastic.co/blog/found-optimizing-elasticsearch-searches

I am attempting to setup the query to look something like this.

{
    "query": {
        "filtered": {
            "query": {
                "query_string": {
                    "query": "ping",
                    "allow_leading_wildcard": false,
                    "default_operator": "AND",
                    "analyzer": "default_search",
                    "default_field": "search_field"
                }
            }
        }
    }
}

So far my query looks like this. I am trying to determine if there is a way to extend or pass all of my current filters I have set in indexVM.

 eui-query="ejs.FilteredQuery(ejs.QueryStringQuery(querystring).allowLeadingWildcard(false).defaultOperator('AND').analyzer('default_search').defaultField('search_field'), <<EITHER BLANK OR EJS FILTER Object>>)

I see that you have written utils for converting an ejsObject into json for comparison and to be put into IndexVM. How would I access the filters and put them as an object into the query?

Thank you for any assistance. Just an IT guy trying to make my team's life easier with search.

thehybridtechnician commented 8 years ago

For anyone on the future wanting to do this, I got it working by doing this...

eui-query="ejs.FilteredQuery(ejs.QueryStringQuery(querystring).allowLeadingWildcard(false).defaultOperator('AND').analyzer('default_search').defaultField('search_field'), indexVM.filters.getAsFilter())"

This can now be closed.