Multi Filitered Facet Queries

Hello,

I'm having trouble getting the following query to return any facet results:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

The following query returns the expected results:
{
"query" : {
"term":{
"tests_passed":"1"
}
},
"facets" : {
"foo" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

As does this one:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
}
}

Am I combigning them improperly? It seems that query is limited to only one
term filter otherwise the filter disapears. Anyone have any advice?

Thanks,
Owen

--
Owen Coutts
University of Waterloo
Email: owen@owencoutts.com

Perhaps a boolean query with two terms query could help ?

Something like :

{

"bool" : {

    "must" : {

        "term" : { " tests_passed " : "4" }

    },

    "must" : {

        "term" : { " tests_failed " : "1" }

    }

}

}

Or

{

"bool" : {

    "must" : {

        "term" : { " tests_passed " : "4" },

        "term" : { " tests_failed " : "1" }

    }

}

}

BTW, why don’t you map tests_xxx fields to number type ? It could be useful
to make range facets (if needed)

Hope this helps

David.

De : owen.coutts@gmail.com [mailto:owen.coutts@gmail.com] De la part de Owen
Coutts
Envoyé : mercredi 22 juin 2011 00:07
À : users@elasticsearch.com
Objet : Multi Filitered Facet Queries

Hello,

I'm having trouble getting the following query to return any facet results:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

The following query returns the expected results:
{
"query" : {
"term":{
"tests_passed":"1"
}
},
"facets" : {
"foo" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

As does this one:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
}
}

Am I combigning them improperly? It seems that query is limited to only one
term filter otherwise the filter disapears. Anyone have any advice?

Thanks,
Owen

--
Owen Coutts
University of Waterloo

Email: owen@owencoutts.com

Hello,

I tried the suggestion to use bool filters:

{
"query" : {
"match_all" : { }
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
},
"filter" : {
"bool" : {
"must" : [
{
"term" : { "tests_passed" : "4" }
},
{
"term" : { "tests_failed" : "1" }
}
]
}
}
}
}
}

But this didn't return facets by the field "system" (It uses slightly
different syntax but I think this is what was meant). Am I going about this
the wrong way?

Thanks,
Owen Coutts

On Tue, Jun 21, 2011 at 3:43 PM, David Pilato david@pilato.fr wrote:

Perhaps a boolean query with two terms query could help ?****


Something like :****

{****

"bool" : {****

    "must" : {****

        "term" : { " tests_passed " : "4" }****

    },****

    "must" : {****

        "term" : { " tests_failed " : "1" }****

    }****

}****

}****


Or****

{****

"bool" : {****

    "must" : {****

        "term" : { " tests_passed " : "4" },****

        "term" : { " tests_failed " : "1" }****

    }****

}****

}****


BTW, why don’t you map tests_xxx fields to number type ? It could be useful
to make range facets (if needed)…****


Hope this helps****

David.****


De : owen.coutts@gmail.com [mailto:owen.coutts@gmail.com] *De la part de

  • Owen Coutts
    Envoyé : mercredi 22 juin 2011 00:07
    À : users@elasticsearch.com
    Objet : Multi Filitered Facet Queries****

Hello,

I'm having trouble getting the following query to return any facet results:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

The following query returns the expected results:
{
"query" : {
"term":{
"tests_passed":"1"
}
},
"facets" : {
"foo" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

As does this one:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
}
}

Am I combigning them improperly? It seems that query is limited to only one
term filter otherwise the filter disapears. Anyone have any advice?

Thanks,
Owen

--
Owen Coutts
University of Waterloo****

Email: owen@owencoutts.com****


Not sure but I think that you have to filter at the same level as query.
Something like :

{
"query" : {
"match_all" : { }
},
"filter" : { ... },
"facets" : { ... } }

as you want to filter the match_all query...

David :wink:

Le 24 juin 2011 à 00:10, Owen Coutts owen@owencoutts.com a écrit :

Hello,

I tried the suggestion to use bool filters:

{
"query" : {
"match_all" : { }
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
},
"filter" : {
"bool" : {
"must" : [
{
"term" : { "tests_passed" : "4" }
},
{
"term" : { "tests_failed" : "1" }
}
]
}
}
}
}
}

But this didn't return facets by the field "system" (It uses slightly different syntax but I think this is what was meant). Am I going about this the wrong way?

Thanks,
Owen Coutts

On Tue, Jun 21, 2011 at 3:43 PM, David Pilato david@pilato.fr wrote:
Perhaps a boolean query with two terms query could help ?

Something like :

{

"bool" : {

    "must" : {

        "term" : { " tests_passed " : "4" }

    },

    "must" : {

        "term" : { " tests_failed " : "1" }

    }

}

}

Or

{

"bool" : {

    "must" : {

        "term" : { " tests_passed " : "4" },

        "term" : { " tests_failed " : "1" }

    }

}

}

BTW, why don’t you map tests_xxx fields to number type ? It could be useful to make range facets (if needed)…

Hope this helps

David.

De : owen.coutts@gmail.com [mailto:owen.coutts@gmail.com] De la part de Owen Coutts
Envoyé : mercredi 22 juin 2011 00:07
À : users@elasticsearch.com
Objet : Multi Filitered Facet Queries

Hello,

I'm having trouble getting the following query to return any facet results:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

The following query returns the expected results:
{
"query" : {
"term":{
"tests_passed":"1"
}
},
"facets" : {
"foo" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

As does this one:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
}
}

Am I combigning them improperly? It seems that query is limited to only one term filter otherwise the filter disapears. Anyone have any advice?

Thanks,
Owen

--
Owen Coutts
University of Waterloo

Email: owen@owencoutts.com

It seems like it doesn't actually filter the facets if you do that.

On Thu, Jun 23, 2011 at 3:16 PM, David Pilato david@pilato.fr wrote:

Not sure but I think that you have to filter at the same level as query.
Something like :

{
"query" : {
"match_all" : { }
},

"filter" : { ... },

"facets" : { ... } }

as you want to filter the match_all query...

David :wink:

Le 24 juin 2011 à 00:10, Owen Coutts owen@owencoutts.com a écrit :

Hello,

I tried the suggestion to use bool filters:

{
"query" : {
"match_all" : { }
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
},
"filter" : {
"bool" : {
"must" : [
{
"term" : { "tests_passed" : "4" }
},
{
"term" : { "tests_failed" : "1" }
}
]
}
}
}
}
}

But this didn't return facets by the field "system" (It uses slightly
different syntax but I think this is what was meant). Am I going about this
the wrong way?

Thanks,
Owen Coutts

On Tue, Jun 21, 2011 at 3:43 PM, David Pilato < david@pilato.fr
david@pilato.fr> wrote:

Perhaps a boolean query with two terms query could help ?****


Something like :****

{****

"bool" : {****

    "must" : {****

        "term" : { " tests_passed " : "4" }****

    },****

    "must" : {****

        "term" : { " tests_failed " : "1" }****

    }****

}****

}****


Or****

{****

"bool" : {****

    "must" : {****

        "term" : { " tests_passed " : "4" },****

        "term" : { " tests_failed " : "1" }****

    }****

}****

}****


BTW, why don’t you map tests_xxx fields to number type ? It could be
useful to make range facets (if needed)…****


Hope this helps****

David.****


De : owen.coutts@gmail.comowen.coutts@gmail.com [mailto:owen.coutts@gmail.com
owen.coutts@gmail.com] De la part de Owen Coutts
Envoyé : mercredi 22 juin 2011 00:07
À : users@elasticsearch.comusers@elasticsearch.com
Objet : Multi Filitered Facet Queries****


Hello,

I'm having trouble getting the following query to return any facet
results:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

The following query returns the expected results:
{
"query" : {
"term":{
"tests_passed":"1"
}
},
"facets" : {
"foo" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

As does this one:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
}
}

Am I combigning them improperly? It seems that query is limited to only
one term filter otherwise the filter disapears. Anyone have any advice?

Thanks,
Owen

--
Owen Coutts
University of Waterloo****

Email: owen@owencoutts.comowen@owencoutts.com****


--
Owen Coutts
University of Waterloo

--
Email: owen@owencoutts.com
Phone: 519.729.3859
Book a Meeting With Me: tungle.me/ocoutts

What you want for facet filters, not "normal" filters.

Whenever you execute a query, you can return results AND a set of
facets unless you select a size of zero. The filters work on the
query and have no affect on the facets.

--
Ivan

On Jun 24, 7:02 pm, Owen Coutts o...@owencoutts.com wrote:

It seems like it doesn't actually filter the facets if you do that.

On Thu, Jun 23, 2011 at 3:16 PM, David Pilato da...@pilato.fr wrote:

Not sure but I think that you have to filter at the same level as query.
Something like :

{
"query" : {
"match_all" : { }
},

"filter" : { ... },
"facets" : { ... } }

as you want to filter the match_all query...

David :wink:

Le 24 juin 2011 à 00:10, Owen Coutts o...@owencoutts.com a écrit :

Hello,

I tried the suggestion to use bool filters:

{
"query" : {
"match_all" : { }
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
},
"filter" : {
"bool" : {
"must" : [
{
"term" : { "tests_passed" : "4" }
},
{
"term" : { "tests_failed" : "1" }
}
]
}
}
}
}
}

But this didn't return facets by the field "system" (It uses slightly
different syntax but I think this is what was meant). Am I going about this
the wrong way?

Thanks,
Owen Coutts

On Tue, Jun 21, 2011 at 3:43 PM, David Pilato < da...@pilato.fr
da...@pilato.fr> wrote:

Perhaps a boolean query with two terms query could help ?****


Something like :****

{****

"bool" : {****
    "must" : {****
        "term" : { " tests_passed " : "4" }****
    },****
    "must" : {****
        "term" : { " tests_failed " : "1" }****
    }****
}****

}****


Or****

{****

"bool" : {****
    "must" : {****
        "term" : { " tests_passed " : "4" },****
        "term" : { " tests_failed " : "1" }****
    }****
}****

}****


BTW, why don’t you map tests_xxx fields to number type ? It could be
useful to make range facets (if needed)…****


Hope this helps****

David.****


De : owen.cou...@gmail.comowen.cou...@gmail.com [mailto:owen.cou...@gmail.com
owen.cou...@gmail.com] De la part de Owen Coutts
Envoyé : mercredi 22 juin 2011 00:07
À : us...@elasticsearch.comus...@elasticsearch.com
Objet : Multi Filitered Facet Queries****


Hello,

I'm having trouble getting the following query to return any facet
results:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

The following query returns the expected results:
{
"query" : {
"term":{
"tests_passed":"1"
}
},
"facets" : {
"foo" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

As does this one:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
}
}

Am I combigning them improperly? It seems that query is limited to only
one term filter otherwise the filter disapears. Anyone have any advice?

Thanks,
Owen

--
Owen Coutts
University of Waterloo****

Email: o...@owencoutts.como...@owencoutts.com****


--
Owen Coutts
University of Waterloo

--
Email: o...@owencoutts.com
Phone: 519.729.3859
Book a Meeting With Me: tungle.me/ocoutts

The last dude may be right: in a facet, you have to use "facet_filter"
instead of "filter".

On Fri, Jun 24, 2011 at 4:02 PM, Owen Coutts owen@owencoutts.com wrote:

It seems like it doesn't actually filter the facets if you do that.

On Thu, Jun 23, 2011 at 3:16 PM, David Pilato david@pilato.fr wrote:

Not sure but I think that you have to filter at the same level as query.
Something like :

{
"query" : {
"match_all" : { }
},

"filter" : { ... },

 "facets" : { ... } }

as you want to filter the match_all query...

David :wink:

Le 24 juin 2011 à 00:10, Owen Coutts owen@owencoutts.com a écrit :

Hello,

I tried the suggestion to use bool filters:

{
"query" : {
"match_all" : { }
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
},
"filter" : {
"bool" : {
"must" : [
{
"term" : { "tests_passed" : "4" }
},
{
"term" : { "tests_failed" : "1" }
}
]
}
}
}
}
}

But this didn't return facets by the field "system" (It uses slightly
different syntax but I think this is what was meant). Am I going about this
the wrong way?

Thanks,
Owen Coutts

On Tue, Jun 21, 2011 at 3:43 PM, David Pilato < david@pilato.fr
david@pilato.fr> wrote:

Perhaps a boolean query with two terms query could help ?****


Something like :****

{****

"bool" : {****

    "must" : {****

        "term" : { " tests_passed " : "4" }****

    },****

    "must" : {****

        "term" : { " tests_failed " : "1" }****

    }****

}****

}****


Or****

{****

"bool" : {****

    "must" : {****

        "term" : { " tests_passed " : "4" },****

        "term" : { " tests_failed " : "1" }****

    }****

}****

}****


BTW, why don’t you map tests_xxx fields to number type ? It could be
useful to make range facets (if needed)…****


Hope this helps****

David.****


De : owen.coutts@gmail.comowen.coutts@gmail.com [mailto:owen.coutts@gmail.com
owen.coutts@gmail.com] De la part de Owen Coutts
Envoyé : mercredi 22 juin 2011 00:07
À : users@elasticsearch.comusers@elasticsearch.com
Objet : Multi Filitered Facet Queries****


Hello,

I'm having trouble getting the following query to return any facet
results:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
},
"facets" : {
"tag" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

The following query returns the expected results:
{
"query" : {
"term":{
"tests_passed":"1"
}
},
"facets" : {
"foo" : {
"terms" : {
"field" : "system",
"size" : 10
}
}
}
}

As does this one:
{
"query" : {
"term":{
"tests_passed":"4",
"tests_failed":"1"
}
}
}

Am I combigning them improperly? It seems that query is limited to only
one term filter otherwise the filter disapears. Anyone have any advice?

Thanks,
Owen

--
Owen Coutts
University of Waterloo****

Email: owen@owencoutts.comowen@owencoutts.com****


--
Owen Coutts
University of Waterloo

--
Email: owen@owencoutts.com
Phone: 519.729.3859
Book a Meeting With Me: tungle.me/ocoutts

--
Adrian Gaudebert
WebDev Intern @ Mozilla
http://adrian.gaudebert.fr