Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search Facets: Histogram Facet - allow to create buckets with one field name, and aggregate valued on another field #219

Closed
kimchy opened this issue Jun 10, 2010 · 6 comments

Comments

@kimchy
Copy link
Member

commented Jun 10, 2010

You can created buckets based on one field values (for example, timestamp), and total/count another field from the same doc.

Here is an example:

{
    query : {
        "match_all" : {}
    },
    facets : {
        "histo1" : {
            "histogram" : {
                "key_field" : "fieldX",
                "value_field" : "fieldY",
                "time_interval" : "5d"
            }
        }
    }
}
@kimchy

This comment has been minimized.

Copy link
Member Author

commented Jun 10, 2010

implemented.

@mootpointer

This comment has been minimized.

Copy link

commented Jun 18, 2010

What if all I want is the bucketed facets, no aggregation?

@kimchy

This comment has been minimized.

Copy link
Member Author

commented Jun 19, 2010

can you give an example?

@mootpointer

This comment has been minimized.

Copy link

commented Jun 20, 2010

So for example I want to know the the count of documents fitting into date buckets.

Eg. I have a document with a created_at field which is a date. I want to know how many have been found each day of the month for the last month, something akin to http://wiki.apache.org/solr/SimpleFacetParameters#Date_Faceting_Parameters

@kimchy

This comment has been minimized.

Copy link
Member Author

commented Jun 20, 2010

The check out #228, it gives you the ability to work within the script on a date object, which has simple constructs to get, for example, the day of month as the key. In order to perform it in the last month, you will need to either execute a filter on the facet, or on the query, depends on the scope of your query (if its already filters by "last month filter).

@kimchy

This comment has been minimized.

Copy link
Member Author

commented Jun 20, 2010

One more thing, you can also define time_interval which is in elasticsearch time format (for example 2d or 1.5h) as the interval. Since dates are represented as millis in the index, this will work.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.