KQL to filter out non published hits
-
03-10-2020 - |
سؤال
I want to use a result source to get all published pages of a type in a sitecollection. In a different result source I want also the drafts so I have enabled this possiblity in the libraries. However I'm unable to get a filter for Published pages to work. I have tested all versions I can think of for Page.x ListItem.x but with no luck.
المحلول
You need Moderation Status (ModStat) for this to work. You need map crawled property to managed property.
Crawled property = ows__ModerationStatus
. "Require Content approval" must be enabled on library (Library Settings > Versioning Settings > Enable "Require content approval for submitted items").
Map that crawled property to managed property for ex. RefinableInt00
.
Go to Site Settings > root > Under Site Collection Administration click Search Schema > Crawled Properties; search for ModerationStatus and add to RefinableInt00
managed property.
Run full crawl.
After full crawl you can use RefinableInt00
in query.
In result source build query something like this:
RefinableInt00=0
(for approved)
RefinableInt00=3
(for draft)
Status | Internal Value
Approved | 0
Rejected | 1
Pending | 2
Draft | 3
Scheduled | 4