Terms facet on a single type

Hi all.

Is it possible to have "type wide" term facets with [all_terms: true] ?
I have 2 types in the same index but when I request a terms facet with
all_terms=true, it returns the terms in the 2 types.
I already tried with a facet filter (see the exemple below) but it was the
same.

{
"query" : {
"match_all" : { }
},
"size":0,
"facets" : {
"ENGINE_FACET" : {
"terms" : {
"field" : "engine",
"size" : 10,
"order" : "term",
"all_terms" : true
},
"facet_filter" : {
"type" : {
"value" : "vehicle1"
}
}
}
}
}

Regards,

--
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.

FYI

Tried with ES version 0.20.6.

On Wednesday, June 12, 2013 11:40:02 AM UTC+2, Mehrez Marouani wrote:

Hi all.

Is it possible to have "type wide" term facets with [all_terms: true] ?
I have 2 types in the same index but when I request a terms facet with
all_terms=true, it returns the terms in the 2 types.
I already tried with a facet filter (see the exemple below) but it was the
same.

{
"query" : {
"match_all" : { }
},
"size":0,
"facets" : {
"ENGINE_FACET" : {
"terms" : {
"field" : "engine",
"size" : 10,
"order" : "term",
"all_terms" : true
},
"facet_filter" : {
"type" : {
"value" : "vehicle1"
}
}
}
}
}

Regards,

--
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.

UP

On Wednesday, June 12, 2013 11:40:02 AM UTC+2, Mehrez Marouani wrote:

Hi all.

Is it possible to have "type wide" term facets with [all_terms: true] ?
I have 2 types in the same index but when I request a terms facet with
all_terms=true, it returns the terms in the 2 types.
I already tried with a facet filter (see the exemple below) but it was the
same.

{
"query" : {
"match_all" : { }
},
"size":0,
"facets" : {
"ENGINE_FACET" : {
"terms" : {
"field" : "engine",
"size" : 10,
"order" : "term",
"all_terms" : true
},
"facet_filter" : {
"type" : {
"value" : "vehicle1"
}
}
}
}
}

Regards,

--
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.

Hi Mehrez,

The all_terms setting indicate whether you want to terms which have had 0
count in the result to be filtered out (all_terms=false) or returned as
well (all_terms=true). Since facets always work with all the terms in the
index, you will may always get terms that belong to all types if you use
all_terms=true. The facet filter works by limiting the documents that are
considered for this facet so all terms of non-vehicle1 types remain on
count 0 but are still returned.

If you want complete separation between types, you might considering using
an index per vehicle type. You can still search all them using an alias if
you need to, or search only one & facet with all_terms=true and get what
you want.

Cheers,
Boaz

On Wednesday, June 12, 2013 11:40:02 AM UTC+2, Mehrez Marouani wrote:

Hi all.

Is it possible to have "type wide" term facets with [all_terms: true] ?
I have 2 types in the same index but when I request a terms facet with
all_terms=true, it returns the terms in the 2 types.
I already tried with a facet filter (see the exemple below) but it was the
same.

{
"query" : {
"match_all" : { }
},
"size":0,
"facets" : {
"ENGINE_FACET" : {
"terms" : {
"field" : "engine",
"size" : 10,
"order" : "term",
"all_terms" : true
},
"facet_filter" : {
"type" : {
"value" : "vehicle1"
}
}
}
}
}

Regards,

--
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.

Thanks Boaz for your clarification.

I fixed it by indexing the property under a different name in each type :slight_smile:

Regards,

On Wednesday, June 12, 2013 2:12:02 PM UTC+2, Boaz Leskes wrote:

Hi Mehrez,

The all_terms setting indicate whether you want to terms which have had 0
count in the result to be filtered out (all_terms=false) or returned as
well (all_terms=true). Since facets always work with all the terms in the
index, you will may always get terms that belong to all types if you use
all_terms=true. The facet filter works by limiting the documents that are
considered for this facet so all terms of non-vehicle1 types remain on
count 0 but are still returned.

If you want complete separation between types, you might considering using
an index per vehicle type. You can still search all them using an alias if
you need to, or search only one & facet with all_terms=true and get what
you want.

Cheers,
Boaz

On Wednesday, June 12, 2013 11:40:02 AM UTC+2, Mehrez Marouani wrote:

Hi all.

Is it possible to have "type wide" term facets with [all_terms: true] ?
I have 2 types in the same index but when I request a terms facet with
all_terms=true, it returns the terms in the 2 types.
I already tried with a facet filter (see the exemple below) but it was
the same.

{
"query" : {
"match_all" : { }
},
"size":0,
"facets" : {
"ENGINE_FACET" : {
"terms" : {
"field" : "engine",
"size" : 10,
"order" : "term",
"all_terms" : true
},
"facet_filter" : {
"type" : {
"value" : "vehicle1"
}
}
}
}
}

Regards,

--
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.