query with DATE FIELD AND RANGE query using dismax - solr

I have got a list of resume ID's with the date field and the experience in some range
My queries are working with standard query handler but not in dismax.
How can I check for the date ranges in between suppose 2009-02-02 to 2010-01-01 using solr's dismax query handler
And HOW to configure range queries like minimum experience [3 TO 5] in dismax..
It works with standard handler..but with qt=dismax, it doesnt work..

Have you tried adding filter queries so the it looks something like this:
fq=date:[2009-02-02T23:59:59.999Z TO 2010-01-01T23:59:59.999Z&fq=experience:[3 TO 5]

solr stores date type field in UTC format, so while querying it needs the date criteria to be in UTC format like date:[2009-02-02T00:00:00.0Z TO 2010-01-01T00:00:00.0Z]

Related

How to filter datetime in solr server

I want to implement datetime range filtering in solr..
Total dates in my DB is 4 Like below,
"2020-02-05T09:33:13.0249513Z","2020-02-06T10:12:51.0527678Z","2020-02-07T07:00:13.0249513Z", "2020-02-10T10:00:13.0249513Z".
Query
date:[05-02-2020T11:00:00Z TO 06-02-2020T11:00:00Z]
Want answer records
"2020-02-05T09:33:13.0249513Z", "2020-02-06T10:12:51.0527678Z"
I solve this issue via Insert Timestamp(1581413679400) in Solr database with actual date (2020-02-11T15:04:39.400Z)and I implementing filtering on Timestamp using [date1TimeStamp TO date2TimeStamp]..It's work nice..
Thank you

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.

Sort result by date difference

We have a solr result queried by a date range +/- 1 Month of the date entered. If i entered 2012-12-01 i get a Result Set from 2012-11-01 to 2013-01-01.
This works fine, but we want to sort the Result after the date difference to the date entered.
For example if we have the Dates:
2012-11-10, 2012-11-30, 2012-12-03, 2012-12-10
we want the Result sorted like this:
2012-11-30, 2012-12-03, 2012-12-10, 2012-11-10
Any Ideas how to accomplish this in solr?
Thanks in advance!
you can just add &sort=sub(date_you_enter,date_fieldname_on_documents) asc parameter to your query. basically sub function will calculate the difference and then you will be able to sort it depending on that result.
for reference you can also check http://wiki.apache.org/solr/FunctionQuery page for more functions that could be useful for you

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

Solr: org.apache.solr.common.SolrException: Invalid Date String:

I am new to solr and this is my first attempt at indexing solr data, I am getting the following exception while indexing,
org.apache.solr.common.SolrException: Invalid Date String:'2011-01-07'
at org.apache.solr.schema.DateField.parseMath(DateField.java:165)
at org.apache.solr.schema.TrieDateField.createField(TrieDateField.java:169)
at org.apache.solr.schema.SchemaField.createField(SchemaField.java:98)
at org.apache.solr.update.DocumentBuilder.addField(DocumentBuilder.java:204)
at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:277)
I understand from reading some articles that Solr stores time only in UTC, this is the query i am trying to index,
Select id,text,'language',links,tweetType,source,location, bio,url,utcOffset,timeZone,frenCnt,createdAt,createdOnGMT,createdOnServerTime,follCnt,favCnt,totStatusCnt,usrCrtDate,humanSentiment,replied,replyMsg,classified,locationDetail, geonameid,country,continent,placeLongitude,placeLatitude,listedCnt,hashtag,mentions,senderInfScr, createdOnGMTDate,DATE_FORMAT(CONVERT_TZ(createdOnGMTDate,'+00:00','+05:30'),'%Y-%m-%d') as IST,DATE_FORMAT(CONVERT_TZ(createdOnGMTDate,'+00:00','+01:00'),'%Y-%m-%d') as ECT,DATE_FORMAT(CONVERT_TZ(createdOnGMTDate,'+00:00','+02:00'),'%Y-%m-%d') as EET,DATE_FORMAT(CONVERT_TZ(createdOnGMTDate,'+00:00','+03:30'),'%Y-%m-%d') as MET,sign(classified) as sentiment from
Why i am doing this timezone conversion is because i need to group results by the user timezone. How can i achieve this?
Regards,
Rohit
Solr dates must be in the form 1995-12-31T23:59:59Z. You're only giving the date part, but not the time.
See the DateField javadocs for more details.
Date faceting is entirely driven by query params, so if we index your events using the "true" time that they happend at (formatted as a string in UTC) you can then select your date ranges using whatever timezone offset is specified by your user at query time as a UTC offset.
facet.range = dateField
facet.range.start = 2011-01-01T00:00:00Z+${useroffset}MINUTES
facet.range.gap = +1DAY
This would return result in the users timezone and there is actually no need to timezone conversion the query and indexing that column separately.
Regards,
Rohit
Credit For Answer: Chris Hostetter (Solr User Group )

Resources