November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
UnifiedSearch uses it's own projection rules (defined and modified in the UnifiedSearchRegistry) and relies on the fact that you are querying for the 'magic' ISearchContent (basically you can say that client.UnifiedSearch() == client.Search<ISearchContent>()). Whenever the API see a query for ISearchConent it will interpret it as a UnifiedSearch request and follow all the rules setup in the UnifiedSearchRegistry (what types to query, what projections to use, what filters to add...). However when you modify the procection using .Select() you will transform the query into a query for a new return type (in this case an anonymous class) and your query will no longer be treated as a UnifiedSearch. You can see this by noting that the GetResult() extensions in your example query are different. The one where you have made a custom projection it will fallback to a 'generic' 'GetResult':
public static SearchResults<TResult> GetResult<TResult>(this ISearch<TResult> search)
where the second query will use the UnifiedSearch 'GetResult':
public static UnifiedSearchResults GetResult(this ITypeSearch<ISearchContent> search, HitSpecification hitSpecification = null, bool filterForPublicSearch = true)
So what happens here is simply that your first query will be 'downgraded' into a basic query for all objects in the index directly implementing ISearchContent. Since you probably don't have any objects implementing it directly the result set will be empty.
To clarify this further what happens in the UnifiedSearch case when calling 'GetResult()' it will interpret the query as a UnifiedSearch and instead of querying for ISearchContent it will lookup all object types in the UnifiedSearchRegistry that are registered for UnifiedSearch and query for them (By default all PageData objects and MediaData).
To maybe simplify (or confuse) you can think of UnifiedSearch as advanced projections (it maps you data (pages, media, custom) when indexing into ISearchContent and when querying into UnifedSearchHit) ) and that any custom Select will override this andl downgrade your query into a generic search.
I am playing around with Projections and it works great until I try it on Unified Search.
Can anyone tell me why (on a Alloy site) get zero matches for the query with an anonymos projection and a whole lot of matches for the one that does not use projections