Histogram facets with a query


(Andrew Harvey-2) #1

Hey there,

I've been playing around a little more with facets and I think I've come up against a limitation in the histogram facet. I'm looking to produce a histogram facet which has a query. Basically imagine the query facet and the histogram facet made sweet sweet love, then you'd have this.

Unless of course, I've missed the fact that this kind of facet already exists...

I've tried doing things like:

"facets": {
    "foo": {
        "histogram": {
            "time_interval": "24H",
            "key_field": "published",
            "query": {
                "query_string": {
                    "query": "foo"
                }
            }
        }
    } ,
    "bar": {
        "histogram": {
            "time_interval": "24H",
            "key_field": "published",
            "query": {
                "query_string": {
                    "query": "bar"
                }
            }
        }
    }
}

But to no avail. Have I just missed this feature, or should I open a bug for it?

I understand that I could do this using multiple requests, but that seems incredibly wasteful.

Any help would be much appreciated.

Andrew

Andrew Harvey / Developer
lexer
m/
t/ +61 2 9019 6379
w/ http://lexer.com.au
Help put an end to whaling. Visit http://www.givewhalesavoice.com.au/

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person or organisation to whom it is addressed. If you are not the intended recipient, you must not copy, distribute or disseminate the information, or take any action in relation to it and please delete this e-mail. Any views expressed in this message are those of the individual sender, except where the send specifically states them to be the views of any organisation or employer. If you have received this message in error, do not open any attachment but please notify the sender (above). This message has been checked for all known viruses powered by McAfee.

For further information visit http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the sender for any damage rising out of any virus infection this communication may contain.

This message has been scanned for malware by Websense. www.websense.com


(Shay Banon) #2

Can you explain a bit what you are trying to do exactly? There is no option
in the histogram facet to provide a query, but you can provide a filter to
further filter the hits the histogram (or any other facet) will run on. Is
that what you are after?

-shay.banon

On Mon, Jul 12, 2010 at 8:43 AM, Andrew Harvey
Andrew.Harvey@lexer.com.auwrote:

Hey there,

I've been playing around a little more with facets and I think I've come up
against a limitation in the histogram facet. I'm looking to produce a
histogram facet which has a query. Basically imagine the query facet and the
histogram facet made sweet sweet love, then you'd have this.

Unless of course, I've missed the fact that this kind of facet already
exists...

I've tried doing things like:

"facets": {
"foo": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "foo"
}
}
}
} ,
"bar": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "bar"
}
}
}
}
}

But to no avail. Have I just missed this feature, or should I open a bug
for it?

I understand that I could do this using multiple requests, but that seems
incredibly wasteful.

Any help would be much appreciated.

Andrew

Andrew Harvey / Developer
lexer
m/
t/ +61 2 9019 6379
w/ http://lexer.com.au
Help put an end to whaling. Visit http://www.givewhalesavoice.com.au/

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person
or organisation to whom it is addressed. If you are not the intended
recipient, you must not copy, distribute or disseminate the information, or
take any action in relation to it and please delete this e-mail. Any views
expressed in this message are those of the individual sender, except where
the send specifically states them to be the views of any organisation or
employer. If you have received this message in error, do not open any
attachment but please notify the sender (above). This message has been
checked for all known viruses powered by McAfee.

For further information visit
http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the
sender for any damage rising out of any virus infection this communication
may contain.

This message has been scanned for malware by Websense. www.websense.com


(Andrew Harvey-2) #3

Not quite what I'm looking for.

Say I want to have histograms for the results of up to 4 queries, all of which being queries. A single global query wouldn't split things up the way I want.

In the earlier example, I was trying to have a histogram for the query "foo" and for the query "bar" across the same result set. A filter on each individual facet would also work, but there doesn't seem to be possible on a per facet basis. Am I wrong in that assumption?

Andrew

On 13/07/2010, at 4:01 AM, Shay Banon wrote:

Can you explain a bit what you are trying to do exactly? There is no option in the histogram facet to provide a query, but you can provide a filter to further filter the hits the histogram (or any other facet) will run on. Is that what you are after?

-shay.banon

On Mon, Jul 12, 2010 at 8:43 AM, Andrew Harvey <Andrew.Harvey@lexer.com.aumailto:Andrew.Harvey@lexer.com.au> wrote:
Hey there,

I've been playing around a little more with facets and I think I've come up against a limitation in the histogram facet. I'm looking to produce a histogram facet which has a query. Basically imagine the query facet and the histogram facet made sweet sweet love, then you'd have this.

Unless of course, I've missed the fact that this kind of facet already exists...

I've tried doing things like:

"facets": {
"foo": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "foo"
}
}
}
} ,
"bar": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "bar"
}
}
}
}
}

But to no avail. Have I just missed this feature, or should I open a bug for it?

I understand that I could do this using multiple requests, but that seems incredibly wasteful.

Any help would be much appreciated.

Andrew

Andrew Harvey / Developer
lexer
m/
t/ +61 2 9019 6379
w/ http://lexer.com.auhttp://lexer.com.au/
Help put an end to whaling. Visit http://www.givewhalesavoice.com.au/

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person or organisation to whom it is addressed. If you are not the intended recipient, you must not copy, distribute or disseminate the information, or take any action in relation to it and please delete this e-mail. Any views expressed in this message are those of the individual sender, except where the send specifically states them to be the views of any organisation or employer. If you have received this message in error, do not open any attachment but please notify the sender (above). This message has been checked for all known viruses powered by McAfee.

For further information visit http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the sender for any damage rising out of any virus infection this communication may contain.

This message has been scanned for malware by Websense. www.websense.comhttp://www.websense.com/

Click herehttps://www.mailcontrol.com/sr/ZmHw4mchlAfTndxI!oX7Ul4TPWxlZJ1auzCPBn9Prj9fIW+ZgW8tKv+78wAJHus16o5Dvy9BQPV8TccP!XTbKg== to report this email as spam.

Andrew Harvey / Developer
lexer

m/
t/ +61 2 9019 6379
w/ http://lexer.com.au

Help put an end to whaling. Visit www.givewhalesavoice.com.auhttp://www.givewhalesavoice.com.au/


Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person or organisation to whom it is addressed. If you are not the intended recipient, you must not copy, distribute or disseminate the information, or take any action in relation to it and please delete this e-mail. Any views expressed in this message are those of the individual sender, except where the send specifically states them to be the views of any organisation or employer. If you have received this message in error, do not open any attachment but please notify the sender (above). This message has been checked for all known viruses powered by McAfee.

For further information visit http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the sender for any damage rising out of any virus infection this communication may contain.


(Shay Banon) #4

Not sure that I still managed to follow exactly what you are after, but let
me guess ;). In a facet, you can define it as a global one (running on all
data, not constrained by the query you execute for search) and then define
filters on it. Is that what you are after?

-shay.banon

On Tue, Jul 13, 2010 at 2:11 AM, Andrew Harvey
Andrew.Harvey@lexer.com.auwrote:

Not quite what I'm looking for.

Say I want to have histograms for the results of up to 4 queries, all of
which being queries. A single global query wouldn't split things up the way
I want.

In the earlier example, I was trying to have a histogram for the query
"foo" and for the query "bar" across the same result set. A filter on each
individual facet would also work, but there doesn't seem to be possible on a
per facet basis. Am I wrong in that assumption?

Andrew

On 13/07/2010, at 4:01 AM, Shay Banon wrote:

Can you explain a bit what you are trying to do exactly? There is no option
in the histogram facet to provide a query, but you can provide a filter to
further filter the hits the histogram (or any other facet) will run on. Is
that what you are after?

-shay.banon

On Mon, Jul 12, 2010 at 8:43 AM, Andrew Harvey <Andrew.Harvey@lexer.com.au

wrote:

Hey there,

I've been playing around a little more with facets and I think I've come
up against a limitation in the histogram facet. I'm looking to produce a
histogram facet which has a query. Basically imagine the query facet and the
histogram facet made sweet sweet love, then you'd have this.

Unless of course, I've missed the fact that this kind of facet already
exists...

I've tried doing things like:

"facets": {
"foo": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "foo"
}
}
}
} ,
"bar": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "bar"
}
}
}
}
}

But to no avail. Have I just missed this feature, or should I open a bug
for it?

I understand that I could do this using multiple requests, but that seems
incredibly wasteful.

Any help would be much appreciated.

Andrew

Andrew Harvey / Developer
lexer
m/
t/ +61 2 9019 6379
w/ http://lexer.com.au
Help put an end to whaling. Visit http://www.givewhalesavoice.com.au/

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person
or organisation to whom it is addressed. If you are not the intended
recipient, you must not copy, distribute or disseminate the information, or
take any action in relation to it and please delete this e-mail. Any views
expressed in this message are those of the individual sender, except where
the send specifically states them to be the views of any organisation or
employer. If you have received this message in error, do not open any
attachment but please notify the sender (above). This message has been
checked for all known viruses powered by McAfee.

For further information visit
http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the
sender for any damage rising out of any virus infection this communication
may contain.

This message has been scanned for malware by Websense. www.websense.com

Click herehttps://www.mailcontrol.com/sr/ZmHw4mchlAfTndxI!oX7Ul4TPWxlZJ1auzCPBn9Prj9fIW+ZgW8tKv+78wAJHus16o5Dvy9BQPV8TccP!XTbKg==to report this email as spam.

Andrew Harvey / Developer lexer

m/ t/ +61 2 9019 6379 w/ http://lexer.com.au

Help put an end to whaling. Visit www.givewhalesavoice.com.au

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person
or organisation to whom it is addressed. If you are not the intended
recipient, you must not copy, distribute or disseminate the information, or
take any action in relation to it and please delete this e-mail. Any views
expressed in this message are those of the individual sender, except where
the send specifically states them to be the views of any organisation or
employer. If you have received this message in error, do not open any
attachment but please notify the sender (above). This message has been
checked for all known viruses powered by McAfee.

For further information visit
http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the
sender for any damage rising out of any virus infection this communication
may contain.


(Andrew Harvey-2) #5

Something like that. The facet can be constrained by the query, it doesn't matter much. I'm just interested in having multiple histograms from multiple queries from one request.

Sorry if I'm not expressing myself very clearly.

Andrew.

Sent on the run.

On 13/07/2010, at 17:16, "Shay Banon" <shay.banon@elasticsearch.commailto:shay.banon@elasticsearch.com> wrote:

Not sure that I still managed to follow exactly what you are after, but let me guess ;). In a facet, you can define it as a global one (running on all data, not constrained by the query you execute for search) and then define filters on it. Is that what you are after?

-shay.banon

On Tue, Jul 13, 2010 at 2:11 AM, Andrew Harvey <mailto:Andrew.Harvey@lexer.com.auAndrew.Harvey@lexer.com.aumailto:Andrew.Harvey@lexer.com.au> wrote:

Not quite what I'm looking for.

Say I want to have histograms for the results of up to 4 queries, all of which being queries. A single global query wouldn't split things up the way I want.

In the earlier example, I was trying to have a histogram for the query "foo" and for the query "bar" across the same result set. A filter on each individual facet would also work, but there doesn't seem to be possible on a per facet basis. Am I wrong in that assumption?

Andrew

On 13/07/2010, at 4:01 AM, Shay Banon wrote:

Can you explain a bit what you are trying to do exactly? There is no option in the histogram facet to provide a query, but you can provide a filter to further filter the hits the histogram (or any other facet) will run on. Is that what you are after?

-shay.banon

On Mon, Jul 12, 2010 at 8:43 AM, Andrew Harvey <mailto:Andrew.Harvey@lexer.com.auAndrew.Harvey@lexer.com.aumailto:Andrew.Harvey@lexer.com.au> wrote:
Hey there,

I've been playing around a little more with facets and I think I've come up against a limitation in the histogram facet. I'm looking to produce a histogram facet which has a query. Basically imagine the query facet and the histogram facet made sweet sweet love, then you'd have this.

Unless of course, I've missed the fact that this kind of facet already exists...

I've tried doing things like:

"facets": {
"foo": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "foo"
}
}
}
} ,
"bar": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "bar"
}
}
}
}
}

But to no avail. Have I just missed this feature, or should I open a bug for it?

I understand that I could do this using multiple requests, but that seems incredibly wasteful.

Any help would be much appreciated.

Andrew

Andrew Harvey / Developer
lexer
m/
t/ +61 2 9019 6379
w/ http://lexer.com.au/ http://lexer.com.au
Help put an end to whaling. Visit http://www.givewhalesavoice.com.au/ http://www.givewhalesavoice.com.au/

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person or organisation to whom it is addressed. If you are not the intended recipient, you must not copy, distribute or disseminate the information, or take any action in relation to it and please delete this e-mail. Any views expressed in this message are those of the individual sender, except where the send specifically states them to be the views of any organisation or employer. If you have received this message in error, do not open any attachment but please notify the sender (above). This message has been checked for all known viruses powered by McAfee.

For further information visit http://www.mcafee.com/us/threat_center/default.asp http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the sender for any damage rising out of any virus infection this communication may contain.

This message has been scanned for malware by Websense. http://www.websense.com/ www.websense.comhttp://www.websense.com

Click herehttps://www.mailcontrol.com/sr/ZmHw4mchlAfTndxI!oX7Ul4TPWxlZJ1auzCPBn9Prj9fIW+ZgW8tKv+78wAJHus16o5Dvy9BQPV8TccP!XTbKg== to report this email as spam.

Andrew Harvey / Developer
lexer

m/
t/ +61 2 9019 6379
w/ http://lexer.com.au http://lexer.com.au

Help put an end to whaling. Visit www.givewhalesavoice.com.auhttp://www.givewhalesavoice.com.au/


Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person or organisation to whom it is addressed. If you are not the intended recipient, you must not copy, distribute or disseminate the information, or take any action in relation to it and please delete this e-mail. Any views expressed in this message are those of the individual sender, except where the send specifically states them to be the views of any organisation or employer. If you have received this message in error, do not open any attachment but please notify the sender (above). This message has been checked for all known viruses powered by McAfee.

For further information visit http://www.mcafee.com/us/threat_center/default.asp http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the sender for any damage rising out of any virus infection this communication may contain.

Andrew Harvey / Developer
lexer

m/
t/ +61 2 9019 6379
w/ http://lexer.com.au

Help put an end to whaling. Visit www.givewhalesavoice.com.auhttp://www.givewhalesavoice.com.au/


Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person or organisation to whom it is addressed. If you are not the intended recipient, you must not copy, distribute or disseminate the information, or take any action in relation to it and please delete this e-mail. Any views expressed in this message are those of the individual sender, except where the send specifically states them to be the views of any organisation or employer. If you have received this message in error, do not open any attachment but please notify the sender (above). This message has been checked for all known viruses powered by McAfee.

For further information visit http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the sender for any damage rising out of any virus infection this communication may contain.


(Shay Banon) #6

Yes, you can do that with the ability to provide facets with both filters
and define if they are global or not. In terms of filters, there is a filter
that can wrap a query, so all the query power is there with filters as well.

-shay.banon

On Tue, Jul 13, 2010 at 10:19 AM, Andrew Harvey
Andrew.Harvey@lexer.com.auwrote:

Something like that. The facet can be constrained by the query, it
doesn't matter much. I'm just interested in having multiple histograms from
multiple queries from one request.

Sorry if I'm not expressing myself very clearly.

Andrew.

Sent on the run.

On 13/07/2010, at 17:16, "Shay Banon" shay.banon@elasticsearch.com
wrote:

Not sure that I still managed to follow exactly what you are after, but let
me guess ;). In a facet, you can define it as a global one (running on all
data, not constrained by the query you execute for search) and then define
filters on it. Is that what you are after?

-shay.banon

On Tue, Jul 13, 2010 at 2:11 AM, Andrew Harvey <Andrew.Harvey@lexer.com.au
Andrew.Harvey@lexer.com.au> wrote:

Not quite what I'm looking for.

Say I want to have histograms for the results of up to 4 queries, all of
which being queries. A single global query wouldn't split things up the way
I want.

In the earlier example, I was trying to have a histogram for the query
"foo" and for the query "bar" across the same result set. A filter on each
individual facet would also work, but there doesn't seem to be possible on a
per facet basis. Am I wrong in that assumption?

Andrew

On 13/07/2010, at 4:01 AM, Shay Banon wrote:

Can you explain a bit what you are trying to do exactly? There is no
option in the histogram facet to provide a query, but you can provide a
filter to further filter the hits the histogram (or any other facet) will
run on. Is that what you are after?

-shay.banon

On Mon, Jul 12, 2010 at 8:43 AM, Andrew Harvey <Andrew.Harvey@lexer.com.au
Andrew.Harvey@lexer.com.au> wrote:

Hey there,

I've been playing around a little more with facets and I think I've come
up against a limitation in the histogram facet. I'm looking to produce a
histogram facet which has a query. Basically imagine the query facet and the
histogram facet made sweet sweet love, then you'd have this.

Unless of course, I've missed the fact that this kind of facet already
exists...

I've tried doing things like:

"facets": {
"foo": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "foo"
}
}
}
} ,
"bar": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"query": {
"query_string": {
"query": "bar"
}
}
}
}
}

But to no avail. Have I just missed this feature, or should I open a bug
for it?

I understand that I could do this using multiple requests, but that seems
incredibly wasteful.

Any help would be much appreciated.

Andrew

Andrew Harvey / Developer
lexer
m/
t/ +61 2 9019 6379
w/ http://lexer.com.au/http://lexer.com.au
Help put an end to whaling. Visit http://www.givewhalesavoice.com.au/
http://www.givewhalesavoice.com.au/


Please consider the environment before printing this email
This email transmission is confidential and intended solely for the
person or organisation to whom it is addressed. If you are not the intended
recipient, you must not copy, distribute or disseminate the information, or
take any action in relation to it and please delete this e-mail. Any views
expressed in this message are those of the individual sender, except where
the send specifically states them to be the views of any organisation or
employer. If you have received this message in error, do not open any
attachment but please notify the sender (above). This message has been
checked for all known viruses powered by McAfee.

For further information visit
http://www.mcafee.com/us/threat_center/default.asp
http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the
sender for any damage rising out of any virus infection this communication
may contain.

This message has been scanned for malware by Websense.
http://www.websense.com/www.websense.com

Click herehttps://www.mailcontrol.com/sr/ZmHw4mchlAfTndxI!oX7Ul4TPWxlZJ1auzCPBn9Prj9fIW+ZgW8tKv+78wAJHus16o5Dvy9BQPV8TccP!XTbKg==to report this email as spam.

Andrew Harvey / Developer lexer

m/ t/ +61 2 9019 6379 w/ http://lexer.com.au
http://lexer.com.au

Help put an end to whaling. Visit www.givewhalesavoice.com.au

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person
or organisation to whom it is addressed. If you are not the intended
recipient, you must not copy, distribute or disseminate the information, or
take any action in relation to it and please delete this e-mail. Any views
expressed in this message are those of the individual sender, except where
the send specifically states them to be the views of any organisation or
employer. If you have received this message in error, do not open any
attachment but please notify the sender (above). This message has been
checked for all known viruses powered by McAfee.

For further information visit
http://www.mcafee.com/us/threat_center/default.asp
http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the
sender for any damage rising out of any virus infection this communication
may contain.

Andrew Harvey / Developer lexer

m/ t/ +61 2 9019 6379 w/ http://lexer.com.au

Help put an end to whaling. Visit www.givewhalesavoice.com.au

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person
or organisation to whom it is addressed. If you are not the intended
recipient, you must not copy, distribute or disseminate the information, or
take any action in relation to it and please delete this e-mail. Any views
expressed in this message are those of the individual sender, except where
the send specifically states them to be the views of any organisation or
employer. If you have received this message in error, do not open any
attachment but please notify the sender (above). This message has been
checked for all known viruses powered by McAfee.

For further information visit
http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the
sender for any damage rising out of any virus infection this communication
may contain.


(Clinton Gormley) #7

I've been playing around a little more with facets and I think I've
come up against a limitation in the histogram facet. I'm looking to
produce a histogram facet which has a query. Basically imagine the
query facet and the histogram facet made sweet sweet love, then you'd
have this.

I haven't tried facets yet, but I think this should do what you want
(untested):

  1. I've used a match_all query to match all docs - you can change this
    to whatever is relevant

  2. histograms need X and Y values, so I've added the _id field to give
    it something to count

  3. I've filtered each histogram using a constant_score filter, which
    can wrap any query.

{
"query": { "match_all": {}},
"facets": {
"foo": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"value_field": "_id"
},
"filter": {
"constant_score" : {
"filter" : {
"query" : {
"query_string" : {
"query" : "foo"
}
}
}
}
}
} ,
"bar": {
"histogram": {
"time_interval": "24H",
"key_field": "published",
"value_field": "_id"
},
"filter": {
"constant_score" : {
"filter" : {
"query" : {
"query_string" : {
"query" : "bar"
}
}
}
}
}
}
}
}


(system) #8