cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any difference between SiteService methods listSites and findSites

mbel
Star Contributor
Star Contributor

Hello,

Could someone explain if there is any difference between the listSites and findSites methods in SiteService when I want to list ALL sites:

List<SiteInfo> listSites = this.siteService.listSites(null, null);

List<SiteInfo> findSites = this.siteService.findSites("*", 0);

Is it possible findSites not to return sometimes all sites?

I used that method but when I created a new Site programatically before calling that method, it doesn't find it at all.

Is it possible the result between listSites and findSites to be different in the above example?

Thank you in advance.

1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

The main difference is in how the filter is applied. listSites only supports retrieving sites where the name / title starts with a specific value where as findSites supports a any-match use case. listSites is designed to make use of DB-based lookups whereas findSites may use index-based queries. This would explain the behaviour you are seeing - since SOLR indexing is asynchronous you may not immediately find a newly created site via findSites.

View answer in original post

1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator

The main difference is in how the filter is applied. listSites only supports retrieving sites where the name / title starts with a specific value where as findSites supports a any-match use case. listSites is designed to make use of DB-based lookups whereas findSites may use index-based queries. This would explain the behaviour you are seeing - since SOLR indexing is asynchronous you may not immediately find a newly created site via findSites.