SOLVED

Filter by Item Version in KQL

%3CLINGO-SUB%20id%3D%22lingo-sub-131857%22%20slang%3D%22en-US%22%3EFilter%20by%20Item%20Version%20in%20KQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131857%22%20slang%3D%22en-US%22%3E%3CP%3EI%20was%20looking%20for%20a%20crawled%20property%20for%20the%20list%20item%20%2F%20document%20version%20-%20stumbled%20on%20a%20few%20such%20as%20_Version%2C%20Version%2C%20Version0%2C%20ows_DocVersion.%26nbsp%3BI%20have%20mapped%20them%20to%20the%20tenant's%20RefineableDecimal00.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOf%20course%2C%20I%20have%20re-indexed%20the%20site%20collection.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20when%20making%20a%20search%20query%20for%26nbsp%3Bthe%20property%2C%20it%20returns%20an%20empty%20value.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20here%20is%26nbsp%3Ba%20test%20KQL%20I%20am%20using%20in%20the%20Chrome%20SP%20Editor%20-%26gt%3B%20PnP%20JS%20Console%3A%3C%2FP%3E%0A%3CPRE%3Eimport%20pnp%2C%20%7B%20SearchQuery%2C%20SearchResults%20%7D%20from%20%22pnp%22%3B%0A%0Apnp.sp.search(%26lt%3BSearchQuery%26gt%3B%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Querytext%3A%20%22Path%3A%5C%22https%3A%2F%2Ftenant.sharepoint.com%2Fsites%2FSite1%2FLibrary1%5C%22%20AND%20Title%3A%5C%22My%20Item's%20Title%5C%22%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20RowLimit%3A%2016%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20SelectProperties%3A%20%5B%22Title%22%2C%20%22RefinableDecimal00%22%2C%20%22Path%22%5D%2C%0A%20%20%20SortList%3A%20%5B%7B%0A%20%20%20%20Property%3A%20'Created'%2C%0A%20%20%20%20Direction%3A%201%0A%20%20%20%7D%5D%0A%20%20%20%20%20%20%20%20%7D).then((response)%20%3D%26gt%3B%20%7B%20console.log(response.PrimarySearchResults)%20%7D)%3C%2FPRE%3E%0A%3CP%3EHas%20anyone%20found%20a%20way%20to%20query%20for%20the%20list%20item%20version%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-132772%22%20slang%3D%22en-US%22%3ERe%3A%20Filter%20by%20Item%20Version%20in%20KQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-132772%22%20slang%3D%22en-US%22%3E%3CP%3EPosting%26nbsp%3Bour%20solution%20as%20somebody%20else%20might%20find%20it%20useful%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20We%26nbsp%3Bmapped%20the%20UI%20Version%20property%20(ows_q_TEXT__UIVersionString)%20to%20one%20of%20the%20Refinable%20Decimals%3C%2FP%3E%0A%3CP%3E2.%20We%20have%20given%20the%20refinable%20decimal%20an%20alias%20(SharePointVersion)%20in%20our%20case.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20we%20were%20able%20to%20sort%2C%20and%20filter%20via%20a%20KQL%20the%20results%2C%20i.e.%26nbsp%3B%3CSPAN%3ESharePointVersion%3C%2FSPAN%3E%26gt%3B%3D2.1%20was%20giving%20us%20items%20with%20version%20greater%20than%20or%20equal%20to%202.1%20-%20it%20seems%20that%20SharePoint%20have%20successfully%20managed%20to%20parse%20the%20decimal%20value%20into%20the%20decimal%20property.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

I was looking for a crawled property for the list item / document version - stumbled on a few such as _Version, Version, Version0, ows_DocVersion. I have mapped them to the tenant's RefineableDecimal00.

 

Of course, I have re-indexed the site collection.

 

However, when making a search query for the property, it returns an empty value.

 

For example, here is a test KQL I am using in the Chrome SP Editor -> PnP JS Console:

import pnp, { SearchQuery, SearchResults } from "pnp";

pnp.sp.search(<SearchQuery>{
            Querytext: "Path:\"https://tenant.sharepoint.com/sites/Site1/Library1\" AND Title:\"My Item's Title\"",
            RowLimit: 16,
            SelectProperties: ["Title", "RefinableDecimal00", "Path"],
			SortList: [{
				Property: 'Created',
				Direction: 1
			}]
        }).then((response) => { console.log(response.PrimarySearchResults) })

Has anyone found a way to query for the list item version?

1 Reply
best response confirmed by Kiril Iliev (Contributor)
Solution

Posting our solution as somebody else might find it useful:

 

1. We mapped the UI Version property (ows_q_TEXT__UIVersionString) to one of the Refinable Decimals

2. We have given the refinable decimal an alias (SharePointVersion) in our case.

 

So we were able to sort, and filter via a KQL the results, i.e. SharePointVersion>=2.1 was giving us items with version greater than or equal to 2.1 - it seems that SharePoint have successfully managed to parse the decimal value into the decimal property.