Getting query count for individula fields in multi match query

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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/13ddfd94-ed9b-4fda-a768-fcd21c14fc37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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 anandv1000@gmail.com 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 elasticsearch+unsubscribe@googlegroups.com.
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 elasticsearch+unsubscribe@googlegroups.com.
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.

Hi Vineeth,

First of all, thank you for your suggestion.

BTW as you suggested, I can only able to get the no of matched documents.
But what I need is the no of matches of the querystring in each field.

I can also make termquery for each field individually, as it would result
in time consumption I dont want to that.

Could you help me out?

Thanks again.

Regards,
Anand

On Wednesday, 4 February 2015 18:58:35 UTC+5:30, vineeth mohan wrote:

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 <anand...@gmail.com
<javascript:>> 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 elasticsearc...@googlegroups.com <javascript:>.
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e2fa7b1b-7720-4e94-885a-12f62b0cd0f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.