Query on _search not working for _count

Hey guys! Hoping you can see what's going on with this more quickly than I
can.

This query:

{"filter":{"and":[{"term":{"SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag
Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"fields":["RE","SU"],"query":""john@test.com"","default_operator":"AND"}}}]}}

Works for _search but not for _count. Thoughts??

Count throws a No query registered for [filter]] error.

Hiya

{"filter":{"and":[{"term":{"SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"fields":["RE","SU"],"query":""john@test.com"","default_operator":"AND"}}}]}}

Look at the docs for search
Elasticsearch Platform — Find real-time answers at scale | Elastic and for count Elasticsearch Platform — Find real-time answers at scale | Elastic
and you'll soon see the difference

clint

Thanks, Clint! Yeah I've been checking those as best I can today. I'm a
little new to ES so it's not jumping out at me at the moment :frowning:

On Monday, April 16, 2012 2:14:20 PM UTC-4, Clinton Gormley wrote:

Hiya

{"filter":{"and":[{"term":{"SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag
Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"fields":["RE","SU"],"query":""
john@test.com"","default_operator":"AND"}}}]}}

Look at the docs for search
Elasticsearch Platform — Find real-time answers at scale | Elastic for count
Elasticsearch Platform — Find real-time answers at scale | Elastic
and you'll soon see the difference

clint

On Mon, 2012-04-16 at 11:33 -0700, JP Toto wrote:

Thanks, Clint! Yeah I've been checking those as best I can today. I'm
a little new to ES so it's not jumping out at me at the moment :frowning:

The search API accepts 'query' and 'filter' parameters, eg:

{
query: { match_all: {}
}

The count API accepts a query, eg:
{
match_all: {}
}

Inconsistent, I know... but that's how it is at the moment

clint

On Monday, April 16, 2012 2:14:20 PM UTC-4, Clinton Gormley wrote:
Hiya
>
>
{"filter":{"and":[{"term":{"SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"fields":["RE","SU"],"query":""john@test.com"","default_operator":"AND"}}}]}}

    Look at the docs for search
    http://www.elasticsearch.org/guide/reference/api/search/request-body.html and for count http://www.elasticsearch.org/guide/reference/api/count.html
    and you'll soon see the difference
    
    clint

Ohhh I see. Gotcha. I appreciate the tip. Just have to figure out how to
rewrite this now for _count. Thanks!

On Monday, April 16, 2012 2:39:57 PM UTC-4, Clinton Gormley wrote:

On Mon, 2012-04-16 at 11:33 -0700, JP Toto wrote:

Thanks, Clint! Yeah I've been checking those as best I can today. I'm
a little new to ES so it's not jumping out at me at the moment :frowning:

The search API accepts 'query' and 'filter' parameters, eg:

{
query: { match_all: {}
}

The count API accepts a query, eg:
{
match_all: {}
}

Inconsistent, I know... but that's how it is at the moment

clint

On Monday, April 16, 2012 2:14:20 PM UTC-4, Clinton Gormley wrote:
Hiya
>
>

{"filter":{"and":[{"term":{"SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag
Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"fields":["RE","SU"],"query":""
john@test.com"","default_operator":"AND"}}}]}}

    Look at the docs for search

Elasticsearch Platform — Find real-time answers at scale | Elastic for count
Elasticsearch Platform — Find real-time answers at scale | Elastic

    and you'll soon see the difference
    
    clint

Clint,

Is it even possible to filter "queries", then, for _count?

On Monday, April 16, 2012 3:05:25 PM UTC-4, JP Toto wrote:

Ohhh I see. Gotcha. I appreciate the tip. Just have to figure out how to
rewrite this now for _count. Thanks!

On Monday, April 16, 2012 2:39:57 PM UTC-4, Clinton Gormley wrote:

On Mon, 2012-04-16 at 11:33 -0700, JP Toto wrote:

Thanks, Clint! Yeah I've been checking those as best I can today. I'm
a little new to ES so it's not jumping out at me at the moment :frowning:

The search API accepts 'query' and 'filter' parameters, eg:

{
query: { match_all: {}
}

The count API accepts a query, eg:
{
match_all: {}
}

Inconsistent, I know... but that's how it is at the moment

clint

On Monday, April 16, 2012 2:14:20 PM UTC-4, Clinton Gormley wrote:
Hiya
>
>

{"filter":{"and":[{"term":{"SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag
Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"fields":["RE","SU"],"query":""
john@test.com"","default_operator":"AND"}}}]}}

    Look at the docs for search

Elasticsearch Platform — Find real-time answers at scale | Elastic for count
Elasticsearch Platform — Find real-time answers at scale | Elastic

    and you'll soon see the difference
    
    clint

On Mon, 2012-04-16 at 12:43 -0700, JP Toto wrote:

Clint,

Is it even possible to filter "queries", then, for _count?

Yes, that's what the filtered query

and the constant score query

are used for.

The 'filter' param on the search API is used for filtering results AFTER
facets have been calculated. For other uses of filters, it is better to
use the filtered or constant score queries instead.

clint

On Monday, April 16, 2012 3:05:25 PM UTC-4, JP Toto wrote:
Ohhh I see. Gotcha. I appreciate the tip. Just have to figure
out how to rewrite this now for _count. Thanks!

    On Monday, April 16, 2012 2:39:57 PM UTC-4, Clinton Gormley
    wrote:
            On Mon, 2012-04-16 at 11:33 -0700, JP Toto wrote:
            > Thanks, Clint! Yeah I've been checking those as best
            I can today. I'm
            > a little new to ES so it's not jumping out at me at
            the moment :-(
            
            The search API accepts 'query' and 'filter'
            parameters, eg:
            
              {
                query: { match_all: {}
              }
            
            The count API accepts a query, eg:
              {
                match_all: {}
              }
            
            Inconsistent, I know... but that's how it is at the
            moment
            
            clint
            > 
            > On Monday, April 16, 2012 2:14:20 PM UTC-4, Clinton
            Gormley wrote:
            >         Hiya
            >         > 
            >         >
            >
            {"filter":{"and":[{"term":{"SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"fields":["RE","SU"],"query":"\"john@test.com\"","default_operator":"AND"}}}]}}
            >         
            >         Look at the docs for search
            >
            http://www.elasticsearch.org/guide/reference/api/search/request-body.html and for count http://www.elasticsearch.org/guide/reference/api/count.html
            >         and you'll soon see the difference
            >         
            >         clint
            >         

Thanks so much, Clint! Appreciate your patience :slight_smile:

On Tuesday, April 17, 2012 5:03:07 AM UTC-4, Clinton Gormley wrote:

On Mon, 2012-04-16 at 12:43 -0700, JP Toto wrote:

Clint,

Is it even possible to filter "queries", then, for _count?

Yes, that's what the filtered query
Elasticsearch Platform — Find real-time answers at scale | Elastic
and the constant score query

Elasticsearch Platform — Find real-time answers at scale | Elastic
are used for.

The 'filter' param on the search API is used for filtering results AFTER
facets have been calculated. For other uses of filters, it is better to
use the filtered or constant score queries instead.

clint

On Monday, April 16, 2012 3:05:25 PM UTC-4, JP Toto wrote:
Ohhh I see. Gotcha. I appreciate the tip. Just have to figure
out how to rewrite this now for _count. Thanks!

    On Monday, April 16, 2012 2:39:57 PM UTC-4, Clinton Gormley
    wrote:
            On Mon, 2012-04-16 at 11:33 -0700, JP Toto wrote:
            > Thanks, Clint! Yeah I've been checking those as best
            I can today. I'm
            > a little new to ES so it's not jumping out at me at
            the moment :-(
            
            The search API accepts 'query' and 'filter'
            parameters, eg:
            
              {
                query: { match_all: {}
              }
            
            The count API accepts a query, eg:
              {
                match_all: {}
              }
            
            Inconsistent, I know... but that's how it is at the
            moment
            
            clint
            > 
            > On Monday, April 16, 2012 2:14:20 PM UTC-4, Clinton
            Gormley wrote:
            >         Hiya
            >         > 
            >         >
            >

{"filter":{"and":[{"term":{"SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag
Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"fields":["RE","SU"],"query":""
john@test.com"","default_operator":"AND"}}}]}}

            >         
            >         Look at the docs for search
            >

Elasticsearch Platform — Find real-time answers at scale | Elastic for count
Elasticsearch Platform — Find real-time answers at scale | Elastic

            >         and you'll soon see the difference
            >         
            >         clint
            >         

One more thing, you can use search_type set to count in the search request
URI, and execute regular search requests and get back just the count.
Effectively, it will be as performant as the count API.

On Tue, Apr 17, 2012 at 10:24 PM, JP Toto james.p.toto@gmail.com wrote:

Thanks so much, Clint! Appreciate your patience :slight_smile:

On Tuesday, April 17, 2012 5:03:07 AM UTC-4, Clinton Gormley wrote:

On Mon, 2012-04-16 at 12:43 -0700, JP Toto wrote:

Clint,

Is it even possible to filter "queries", then, for _count?

Yes, that's what the filtered query
Elasticsearch Platform — Find real-time answers at scale | Elastic**
filtered-query.htmlhttp://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html
and the constant score query
Elasticsearch Platform — Find real-time answers at scale | Elastic**
constant-score-query.htmlhttp://www.elasticsearch.org/guide/reference/query-dsl/constant-score-query.html
are used for.

The 'filter' param on the search API is used for filtering results AFTER
facets have been calculated. For other uses of filters, it is better to
use the filtered or constant score queries instead.

clint

On Monday, April 16, 2012 3:05:25 PM UTC-4, JP Toto wrote:
Ohhh I see. Gotcha. I appreciate the tip. Just have to figure
out how to rewrite this now for _count. Thanks!

    On Monday, April 16, 2012 2:39:57 PM UTC-4, Clinton Gormley
    wrote:
            On Mon, 2012-04-16 at 11:33 -0700, JP Toto wrote:
            > Thanks, Clint! Yeah I've been checking those as best
            I can today. I'm
            > a little new to ES so it's not jumping out at me at
            the moment :-(

            The search API accepts 'query' and 'filter'
            parameters, eg:

              {
                query: { match_all: {}
              }

            The count API accepts a query, eg:
              {
                match_all: {}
              }

            Inconsistent, I know... but that's how it is at the
            moment

            clint
            >
            > On Monday, April 16, 2012 2:14:20 PM UTC-4, Clinton
            Gormley wrote:
            >         Hiya
            >         >
            >         >
            >
            {"filter":{"and":[{"term":{"**

SID":"49"}},{"term":{"BI":"true"}},{"term":{"TA":"Tag
Test"}},{"term":{"TY":"2"}},{"query":{"query_string":{"
fields":["RE","SU"],"query":"**"john@test.com"","default_

operator":"AND"}}}]}}

            >
            >         Look at the docs for search
            >
            http://www.elasticsearch.org/**

guide/reference/api/search/**request-body.htmlhttp://www.elasticsearch.org/guide/reference/api/search/request-body.htmland for count
Elasticsearch Platform — Find real-time answers at scale | Elastichttp://www.elasticsearch.org/guide/reference/api/count.html

            >         and you'll soon see the difference
            >
            >         clint
            >