SharePoint Search SQL: Search by location and below (dynamic)

I have a client application that is a complete SharePoint structure (sitecollections, sites and subsites, doclibs, folders) of any third SharePoint site as a navigation tree.

Users can click any level in this tree and search freetext. They expect their search results to appear either in the selected location or below. For instance,

if they click on a site, they only need results on this site. if they click on a folder, they only need results from this folder and any subfolders.

I am trying to accomplish this using the PATH property constraint. However, whenever I turn on the LIKE predicate in PATH, the search results become empty. What am I doing wrong?

SharePoint Search SQL:

SELECT URL,Path,FileName,Version,Size,LastModifiedTime,DocID FROM Scope() WHERE ContentClass='STS_ListItem_DocumentLibrary' AND Path LIKE 'http://servername/doclib001/%' AND FREETEXT(DEFAULTPROPERTIES, 'test' ) 

(SharePoint2010)

+4
source share
1 answer

Querying a path never gives any results. However, requesting a Site with an equality predicate operator does exactly what I want, i.e.

 SELECT URL,Path,FileName,Version,Size,LastModifiedTime,DocID FROM Scope() WHERE ContentClass='STS_ListItem_DocumentLibrary' AND Site = 'http://servername/doclib001' AND FREETEXT(DEFAULTPROPERTIES, 'test' ) 

gives results from doclib001 als, as well as doclib001 / folder001 and below. This is quite unexpected, given that (a) the site offers a site / website, not an arbitrary URL, and (b) I use an exact equal operator, not like / contains ... but it works beautifully, so I don’t complaining!

Non-recursive searches so far seem pretty impossible.

+1
source

All Articles