Constant_score, filtered and filter in a query

Hi All,

My understanding is that filtered executes on the results of the filter.
I'm trying to include the filtered along with the filter wrapped by
constant_score. I'm trying to understand how the query works.

My document structure
ID,List,Date : Date

{
"filtered" : {
"query" : {
"term" : { "Date" : "xxx" }
},
"query": {
"constant_score": {
"filter": {
"terms": { "DataIds": [ 61, 71], "execution": "and", "_cache":
true }
}
}
}
}
}

The above query is to get the count of documents, whose DataIDs contains
61,71 and document date is xxx and I have 50 million documents across 5
shards. I'm trying to figure out the best possible way to achieve this. I'm
using _msearch with search_type as count in the header.

  1. Is the filter section broken down to 2 separate filters 61, 71 that are
    executed separately and results are intersected ? Or is the filter
    [61,71] executed at once meaning the iterate the data set once ?

  2. Help structuring the above query. I get syntax errors

  3. Is filtered section parallel like filter executed on all the shards or
    the results aggregated to once place and results are further filter there ?

Any help is appreciated,

Thanks.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I am not sure why you need constant_score here, but I think that the query
that you had in mind is this:

{
"filtered": {
"query": {
"term": {
"Date": "xxx"
}
},
"filter": {
"terms": {
"DataIds": [61, 71], "execution": "and", "_cache": true
}
}
}
}

The "terms" filter will create an individual term filters for each term and
then combine them using "and" filter so it will iterate over data once. The
filter will be executed on all shards.

On Monday, April 15, 2013 4:21:01 PM UTC-4, Abhishek Andhavarapu wrote:

Hi All,

My understanding is that filtered executes on the results of the filter.
I'm trying to include the filtered along with the filter wrapped by
constant_score. I'm trying to understand how the query works.

My document structure
ID,List,Date : Date

{
"filtered" : {
"query" : {
"term" : { "Date" : "xxx" }
},
"query": {
"constant_score": {
"filter": {
"terms": { "DataIds": [ 61, 71], "execution": "and", "_cache":
true }
}
}
}
}
}

The above query is to get the count of documents, whose DataIDs contains
61,71 and document date is xxx and I have 50 million documents across 5
shards. I'm trying to figure out the best possible way to achieve this. I'm
using _msearch with search_type as count in the header.

  1. Is the filter section broken down to 2 separate filters 61, 71 that are
    executed separately and results are intersected ? Or is the filter
    [61,71] executed at once meaning the iterate the data set once ?

  2. Help structuring the above query. I get syntax errors

  3. Is filtered section parallel like filter executed on all the shards or
    the results aggregated to once place and results are further filter there ?

Any help is appreciated,

Thanks.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.