YousefED / ElasticUI

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

Searching on multiple fields #84

Open tarandhupar opened 8 years ago

tarandhupar commented 8 years ago

Hello, Is there a way to specify multiple fields for eui-searchbox. I would like this to search on more than one field.

manateeit commented 8 years ago

You will likely have to use the components and build it yourself. https://github.com/YousefED/ElasticUI/blob/master/docs/components.md.

You are going to use the eui-query and then build your query in ejs, just like you would in Query language.

<input type="text" eui-query="ejs.MatchQuery(field, querystring)" ng-model="querystring"/>
{
    "multi_match": {
        "query":    "full text search",
        "fields":   [ "title", "body" ]
    }
}

I am very new to this and the ejs documentation site is not responding.. but it should be something like this.

<input type="text" eui-query="ejs.MultiMatch().query(querystring).fields('title','body') ng-model="querystring"/>

I don't believe my syntax is 100% correct, as I am trying to figure out how to do a range query this way with two input fields. Maybe this will give you enough to figure out the correct syntax.

manateeit commented 8 years ago

There is one thing I forgot in the above that is need to make it work, besides getting your syntax correct. is to either eui-enabled = true someone on the page. Or setup a button or click to enable and disable query.enabled

tarandhupar commented 8 years ago

For now I am using _all in the field parameter, I will revisit this when I get to a better place in my code and post my findings. Thanks for your quick response.