Solr field for storing range - solr

Is there a solr field type that would work well storing a range of two values?
For example, I'm trying to store a min and max cost for each document i.e. $0 to $100, or $50 to $100
I'd then want to be able to query a single value to see if it falls in the range. i.e. which documents' range allows $25?
I realize a workaround would be to store min and max separately, but wondering if any native fields support this to simplify querying?

There is no field which stores data range as integer and providing results according to that data. You can have a look at Solr field here
As you said you can keep min and max as separate fields and it will not make your query complicated. You only need to have value < field_max && value > field_min. this query in your solr query.

Related

Mongodb huge date index size

I have a mongodb database storing documents with a publication date and an end date. For my request i need to create an index with both on those dates.
My collection size is about 17GB for a total of 6 Millions documents.
When i create my index, the index size is about 600MB ... but when i use it intensively, the size get up to 70GB ... 6 times more than the documents themselves oO
Am i doing something wrong ? Is there some special considerations with date fields ? (I only have problem with date indexes).
Note: I suspected my dates to be "too precises" to be indexed, so i rounded them to the nearest hour ... without any index size decrease.
Okay i've found the reason of this really strange bug. I am putting it here since it can happens to others.
I'm using moment.js for managing dates on node.js
I'm using mongodb driver directly (not mongoose)
(I forgot to precise it in my question), i make an update on my dates in my intensive scripts.
I update those dates with a moment object instead of a pure javascript date making mongodb try to index every bit of subpath i think which is responsible of this huge index size.

Google Data Studio, how to get a sum of all Max or Min values

I am working with a data set where i have to get Min or Max for different text fields. My dataset can have thousands of rows so below is a simpler example. So I have 3 categories having multiple values and I can put this dataset in GDS to build a table where I select Category as dimention and Value as Max(Value) in metric.
Now I need to see the sum of all those values too. But like the pivot table in excel, the subtotal in GDS shows the Max out of all the max listed above. So instead of 65, it shows 30 in GDS. Is there a way I can get it to show the sum?
To reach the desired result you will need:
Make a data combination, not being necessary to insert a second base, just so that a current base is defined as a data combination.
In the combination use the Category dimension and define the Max Value metric. The combination is only necessary for the metric to be used in the table as a dimension (this is a property resulting from the combination of data).
Configure the table with the Category dimension and Include the metric with the Value sum option. Remember that now Value is the maximum value (as defined in the data combination).
Finally, display the Summary line. And the desired result is obtained

Applying a range filter only for a particular field with specific value in SOLR

I have data indexed into solr as with fields like :-
name:Apples weight:5kg
name:Grapes weight:2kg
name:papaya weight:7kg
name:Apples weight:3kg
name:Grapes weight:3kg
I want my results to be shown in such a way that all my results except Apples comes as usual results and after that the results for apples are shown at the end that too with weight range of 4-8 kg only.
i.e the results for apples are shown at the end that too with a particular weight range.
First you'll have to limit the documents you want to your criteria - i.e. you want all documents, except for those that are apples and outside of 4-8kg (this assumes that your weight field is an integer - if it isn't - make it an integer field so that you can do proper range searches):
q=(*:* NOT name:Apples) OR (name:Apples AND weight[4 TO 8])
Then you can apply a negative boost to Apples (which you do by boosting everything that doesn't match by a large factor):
bq=(*:* -name:Apples)^1000

Does OpenTSDB can perform 'clever' query?

I really need to know if openTSDB database can perform some clever query. There are no lot of example shared.
For example, i need average for one dataset values, with zero values excluded.
Now i have something like this:
http://localhost:4242/api/query?start=1480892400&end=1483657140&m=sum:32d-avg:site.availability{siteId=73}&arrays=true&ms
This query takes start & end date timestamps, 32 days downsample parametar and 'avg' as average aggregate function, metrics name, tag and response format.
My time data series looks like:
[
[1483142484722, 210],
[1483142548883, 203],
[1483142609002, 0]
]
Etc...
This query returns one single value as expected, that is average of all values in my dataset. I need query that returns average for all, except '0' values, i don't wont zero values affect my calculations.
Can we do something like that in openTSDB ?

Sum field by date range

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

Resources