I’m working on a project with Mike McNett where we have multiple calendars across multiple sites in a site collection. We need to create a single view where upcoming events can be viewed from one central location.
We started with Content Search Web Part (CSWP) since it can retrieve all calendar events.
So here’s the path we took:
1. Added Content Search Web Part to a page
2. Changed Query from “Recently changed items (System)” to “Items matching a content type (System)”
3. Changed Restrict by app from “Current site” to “Current site collection”
4. Changed Restrict by tag from “Do not restrict on content type” to “Event”
5. Switched to Advanced Mode
Note: You can change the path the Query text to include all site collections by removing <sitecollection> from the URL. If you want to include all lists in your farm, remove the path value all together.
ContentTypeId:0x0102* indicates “Event” we selected earlier.
6. Clicked Test Query
In the SEARCH RESULT PREVIEW, all events returned. In our case, 10 results (This includes past, present, and future dates)
So far so good.
Since we only wanted future events to return, we started adding a filter.
7. Changed Property filter to:
StartDate>={Today}
In the SEARCH RESULT PREVIEW, Results=0. (There are five (5) events that meet this criteria.)
We tried different properties, including EndDate, and everything with the word “Date”, still the SEARCH RESULT PREVIEW, returned 0 or a syntax error. We checked to make sure that content has been indexed.
Note: Comparing anything with OWSDATE to {Today} gave us a syntax error. (I’ll explain why later.)
Below is the screenshot when comparing AnythingOWSDATE to {Today}.
After a lot of head-scratching, we started looking into Search Schema. (This can be done at a site collection or a farm level.)
In the Managed property, we typed “date” (without the double quotes). Here’s where we saw OWSDATE is a “Text” type.
A light bulb went off, this is why comparing {Today} to AnythingOWSDATE caused the Syntax error I mentioned earlier. (At least this made sense to me.)
8. So we edited the Date00 Property to the following:
8.a Queryable: checked, Retrievable: checked, Refinable: Yes – active, Sortable: Yes – active;
And affter many tries, these are the settings we used:
8.b Mappings to crawled properties:
Include content from the first crawled property that is not empty, based on the specified order
Ows_EventDate
Ows_q_DATE_EventDate
9. Started a Full Crawl
10. Went back to the CSWP, and added Date00>={Today}….drum rolls….
It worked!!!
The SEARCH RESULT PREVIEW showed five (5) events.
We went back and modified the CSWP properties to include the desired settings, and here’s the final result.
We hope this helps those who have similar requirements.
this was helpful!
When I try your solution I hit a roadblock when I try to edit the Date00 property, I cannot make any edits. I am a site collection admin so permissions should not be the reason. Any thoughts on why I wouldn’t be able to make changes to the Date00 property?
Jared,
If you select ‘Schema’ under Search in Site Settings, you’d only see ‘View Property’. Be sure you select ‘Search Schema’ under ‘Site Collection Administration’, and you should be able to map the desired properties.
Pingback: Developing for SharePoint 2013 | Shawn Tucker
THANK YOU so much ! 2 days of digging over the net to find your perfect article describing the solution in details to this really annoying problem…
Thanks again Veenus !
Quick question, does it work correctly? We have an issue that {Today} in search is GMT. But the date we enter is GMT +1 (Belgium). So when we say that an item should be seen tomorrow in search, actually it is already today.
These are the settings:
– today is 14/11/2013
– startDate is 15/11/2013
– in our query we say “{Today} >= startDate”
– only when query is correct, the item would be visible.
The item would be visible from 15/11/2013, but it’s already visible today..
– Why is it visible?
We live in GMT +1, search is at GMT, so at 14/11/2013 23:00 the item would be visible (our date minus 1 hour).
But our startDate has no time field, it’s only a date, so the time is discarded and the item is visible at 14/11/2013…
Have you got the same issues with your timezone?
Hello Geoffrey.
I have the same issue with French timezone.
Did you find the bug?
Regards
Fabien
Hi, we’re can i find the manage property section? for me to edit the Date00? Thanks
This works great! Thank you.
I just want to state that this will work for all event EXCEPT recurring event. After, trying this i noticed that all the events will works as explained except recurring one. After checking the results using the Search Query Tools, realized that Ows_EventDate and Ows_q_DATE_EventDate are the start date of the recurring series of event and not in that case the start date of the event.
Hi! Sorry for commenting on an old article, but does this work for recurring events?
Hi Thomas, did you ever find a solution for recurring events?
If anyone has any tips on getting the recurring events to display, I’d love to hear them too.
Hi,
Thanks for the helpful post. I need below two things for my project
1.Need to change the format for Date
2.Display the date with time
Can you please give the answer for above question?
A Big Thank you 🙂 Good Explanation, It was helpful.
This worked wonders Thanks. If you are sorting announcements by expiry date, you use the following mappings:
Ows_Expires
Ows_q_DATE_Expires
Reblogged this on My code stories.
Hello Veenus,
I do not have the mapping for Ows_EventDate in my Search Schema. Do I have to create this? I would have thought it was OTB.
Thanks for your comment.
Tim
Awesome, very detailed and easy to follow. As long as you know search, Queries and Search Schema this is a breeze with your article. 🙂
Pingback: Where Is Search Settings And Indexed Content In Sharepoint | Coojoyka
Wondering if changing that variable at th site collection level would affect all of the other sites in the collection – we have over 100 sites. Could you advise if that is the case. I would think that only the sites that utilize that field but not sure how to check that
Any idea how to do this in the modern page experience? With highlighted content web part? 🙂