Question

Trying to search specific lists by passing in the list paths.

path={0}+path={1}+path={2}

Is this possible? Dose the above code look correct? No results are currently returning.

Was it helpful?

Solution 2

Correct syntax is: Path:URL

KeywordQuery keywordQuery = new KeywordQuery(site);

string strQuery = "*";

foreach (string strPath in allLists)
{
   strQuery += String.Format(" Path:{0}", strPath);
}

keywordQuery.QueryText = strQuery + " (contentclass:STS_ListItem OR contentclass:STS_ListItem_DocumentLibrary)";

OTHER TIPS

The thing about using path in your search queries is that it treats any value as an absolute path, meaning it doesn't support relative paths. You might see examples of it working though, but it is highly unlikely you will get the desired results.

It is best to make the search terms as specific as possible.
E.g. specify one or more content types; or include partial/full list titles (depending on requirements).

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top