Hi ,
There is a way to do it.
You need to use the filter aggregation
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html>
.
Keep 2 filters one for match on subject field and other on message field.
{
"query": {
"multi_match": {
"query": "this is a test",
"fields": [
"subject",
"message"
]
}
},
"aggs": {
"messageField": {
"filter": {
"query": {
"match": {
"message": "this is a test"
}
}
}
},
"subjectField": {
"filter": {
"query": {
"match": {
"subject": "this is a test"
}
}
}
}
}
}
Thanks
Vineeth Mohan,
Elasticsearch consultant,
qbox.io ( Elasticsearch service provider <http://qbox.io>)
On Wed, Feb 4, 2015 at 6:44 PM, Anand kumar <[email protected]> wrote:
>
> Hi all,
>
> Is it possible to get the query count per field, while querying
> via multi match query?
>
> {
> "multi_match" : {
> "query": "this is a test",
> "fields": [ "subject", "message" ]
> }
> }
>
> In above query, can i able to get the the no of matches from the
> subject field and message field, is there any other way to make it?
>
> Any suggestion would be helpful.
>
> Thanks in advance.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/13ddfd94-ed9b-4fda-a768-fcd21c14fc37%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/13ddfd94-ed9b-4fda-a768-fcd21c14fc37%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAGdPd5ncEk9w%2ByFObk%3DHcCZpftBFdndLte9YNt7hDMnZuea36A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.