Sum field by date range - solr

I'm using solr 3.6 and I'm kinda stuck trying to perform a special query.
I'm actually using facets by date range, the face.date.gap is set to +1DAY. Of course, the facet is supposed to return the count of docs at a date range but I also need to get the sum of a special field at the same ranges used in facet. It's like I need to count how many votes I have daily monthly, weekly, whatever... it depends on the gap params.
Any ideas? Should I use the group.query or facet.query?

One suggestion I have is to treat the weeks, days separately, and index them. For ex. Today is part of 24th week. Another suggestion is not to rule out multiple searches to service one request. One to calculate all oth facets and one to return counts for given date range (based on search results from first query).

Related

Index Match multiple criteria and multiple rows google sheets

I am trying to match date and time, and metric category with multiple rows in a data sheet. Currently, I record metrics every day in a similar function with a set of rows showing metric data based on intervals of time. These rows are broken up by date.
I would like to be able to add to a dashboard the current metrics without someone needing to dig through the tables I am recording in. This would require the metric to stay up there until the next interval changed.
I will use =SPLIT(NOW) for the date and time but for now I would like to at least get this to work with static interval and date. I tried using Index Match using AND(), & etc and I cannot get it to work. I also tried to use an array but it errors every time.
Google Sheets Index Match Multi Criteria
If the time intervals for each day will be exactly the same and the data structure will never change with 3 identical lines per day (as per your screenshot) than I think you are overcomplicating things a little:
B2:
=index($A$7:$E$15,MATCH($A$1,$A$7:$A$15,0)+1,MATCH(B$1,$A$7:$E$7,0))
B3:
=index($A$7:$E$15,MATCH($A$1,$A$7:$A$15,0)+2,MATCH(B$1,$A$7:$E$7,0))
B4:
=index($A$7:$E$15,MATCH($A$1,$A$7:$A$15,0)+2,MATCH(B$1,$A$7:$E$7,0))

Solr calculate last day of month

I am building a Solr
Index where data has date I need to calculate a field if date was last day of month?
I would prefer if I can do
It at query time, tried few things unsuccessfully any ideas
if you mean 'a field that says if the date in another field is the last day of THAT month', then it makes much more sense to do it at index time:
it will be more performant, you index it as a boolean, and no calculation needs to happen at query time, just matching it
you have several of ways to compute it: at the client side (the easiest), in a UpdateRequestProcessor, tansformer if you are doing DIH,
maybe some crazy regex can do it in a copyfield...

What is the optimized way for queries on partial dates in GAE Text Search?

Need to get entities filtering by month instead of complete date values (E.g. Birthdays) using Google App Engine Text Search. On verifying GAE docs, I think it is not possible to query date fields by month directly.
So in order to filter them by month/date, we consider saving each date sub value like Date(DD), Month(MM) and Year(YYYY) as separate NUMBER field along with complete date field.
I verified locally that we can achieve by saving like this. But is this the correct way of saving dates by splitting each field when we want to query on date sub values?
Is there any known/unknown limit on number of fields per document apart from 10GB size limit in GAE Text Search?
Please suggest me.
Thanks,
Naresh
The only time NUMBER or DATE fields make sense is if you need to query on ranges of values. In other cases they are wasteful.
I can't tell from your question exactly what queries you want to run. Are you looking for a (single) specific day of the month (e.g., January 6 -- of any year)? Or just "anything in June (again, without regard to year)"? Or is it a date range: something like January 20 through February 19? Or July 1 through September 30?
If it's a range then NUMBER values may make sense. But if it's just a single specific month, or a single month and day-of-month combination, then you're better off storing month and day as separate ATOM fields.
Anything that looks like a number, but isn't really going to be searched via a numerical range, or done arithmetic on, isn't really a number, and is probably best stored as an ATOM. For example, phone numbers, zip codes (unless you're terribly clever and wanting to do something like "all zip codes in San Francisco look like 941xx" -- but even then if that's what you want to do, you're probably better off just storing the "941" prefix as an ATOM).

Solr match any date in given month

In Solr, is it possible to search for all records in a given month regardless of the year or day ? For example, the snippet below would match everything on 01.01.2013 - what I want to do is find everything that appeared on 01.01 for any year.
date:2013-01-01T00:00:00Z
No, not with a date field. Solr can only deal with ranges of dates, just like it only deals with ranges of numbers or ranges of strings. Asking Solr to only query a date field based on the first day of the month is like asking it to query on a numeric field and only give you odd numbers, or querying a string but only those starting with vowels.
What you'll need to do is break up the date into month and day components and then query on those. If your base field is sale_date, you'll also need sale_month and sale_day. Then you can query on month:3 to get everything that happened in any March, or day:1 and get everything for the first day of any month or month:3 AND day:1 to get everything that happened on any March 1st.

Filtering on two different dates on the same filter in Solr

In Solr, if you have an indexed piece of data, and within that data you had a set of date values, how can you query against the index and ask for events between X and Y date?
For example, if I have a list of Event Venues, each with dozens of events (single, all day, or multi-day), how would you construct the filter to return venues whos events are between the start and end date specified in a search?
Right now, if I search in a form and submit it through to Solr, the query string looks like this:
&fq=dm_event_start_date\:value:["2013-01-04T05:00:00Z" TO *]
&fq=dm_event_end_date\:value:[* TO "2013-01-08T05:00:00Z"]
&fq=bm_tickets_left\:value:"TRUE"
What I really want to ask for are events that occur or start on January 4th, don't last beyond January 8th, AND still have tickets left.
I feel like what I am getting in return is any event that either falls between the two dates, or has tickets available- not necessarily matching the dates.
Probably the date field values needs to be out of the quote in the range query e.g. :-
&fq=dm_event_start_date:value:[2013-01-04T05:00:00Z TO *]
&fq=dm_event_end_date:value:[* TO 2013-01-08T05:00:00Z]
&fq=bm_tickets_left:value:true
Also the bm_tickets_left needs to be just the string value.

Resources