ElasticUI icon indicating copy to clipboard operation
ElasticUI copied to clipboard

Searching on multiple fields

Open tarandhupar opened this issue 9 years ago • 3 comments

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

tarandhupar avatar May 09 '16 15:05 tarandhupar

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 avatar May 10 '16 02:05 manateeit

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

manateeit avatar May 10 '16 18:05 manateeit

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.

tarandhupar avatar May 11 '16 01:05 tarandhupar