KQL Query - Sharepoint 2013 Search - Filter by empty date value

Hey,

I'm using Microsoft.Office.Server.Search.Query.KeywordQuery class to query the search service. By using the following KQL query, I can get all the crawled items of a specific content type filtered by Expiration Date:

(ContentType:"MyContentType") (PublishingExpirationDateOWSDATE>=2013/08/07)

PublishingExpirationDateOWSDATE is of type Date (it's not the default metadata property that SP creates when you do a full crawl, since that one is of type text, i deleted and recreated it as date time). I just did this because i needed to be able to sort the results by that value, and it was impossible when it was just text.

So, now my problem comes when i want to include those values where the PublishingExpirationDateOWSDATE > (today) or are emtpy (in other words, the not expired items).

I found no way of targeting the items where the date is empty. Is there some way? Some special syntax to get them?

I just come up with another idea, that would be having another managed property bound to the same crawled property of type "text", and just comparing that one to "". But i don't want to have the need of having to separate properties.

Is there som

August 7th, 2013 5:32pm

There is no way to search against null values, since these are not stored in the index. The only way is to do filtering after the results are returned using custom code.
Free Windows Admin Tool Kit Click here and download it now
August 8th, 2013 9:39pm

Hi Antonio,

Search does not create index of any field which is left empty. A query filtering data based on PublishingExpirationDateOWSDATE > (today). Will give you all the records with date greater than today's date ignoring the time also.  Records with date empty will not appear in your results. 

You will not be able to achieve this with custom search results web part also.

Try CQWP.


August 31st, 2013 9:15am

Hi

Not sure if this is what you mean but I used this on the end of my search content query advanced query..

-PropertyName:("*")

This removes all items where this is any character in the property name.

Free Windows Admin Tool Kit Click here and download it now
November 14th, 2014 10:19am

Agnes Molnar has your answer.

http://www.itunity.com/article/filter-empty-values-search-693

For example, I wanted to exclude all expired items without excluding items that have no expiration date.

So based on the referenced example, I added:

-ExpirationTime:1900-01-01..{Today-1}

So any result that does have an expiration date, and whose expiration date is less than today, does not get returned.

March 31st, 2015 3:43am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics