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


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

  • I don't know what the rest of your query looks like, but wouldn't you want (path={0} or path={1} or path={2}) and {searchterm}? Give me all the {searchterms} that come from path 1 or path 2 or path 3? Apr 1, 2016 at 20:17
  • i'm using "*" as a search term because i want all list items returned. Thanks for the correct syntax for multiple lists. Apr 1, 2016 at 20:39
  • @EricAlexander - if I want all list items return would i use "*" as the search term? Apr 1, 2016 at 20:52
  • you wouldn't necessarily have to if you are configuring a search results web part, just the paths will bring back everything Apr 2, 2016 at 0:41
  • You will make your life significantly easier if you use Content Types. Using path is awful. Apr 2, 2016 at 12:28

2 Answers 2


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).


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)";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.