1

We have customized SXA search in our project. There are few predicates from SearchService of Sitecore.XA.Foundation.Search dll used.

To enhance the performance I was trying to cache query to avoid database latency (since data hardly change) and suddenly PageOrMediaPredicate predicate stopped fetching data. I reverted my changes and it worked again.

There is something wrong when I get query from cache. I am completely blank about what that predicate does. I went to declaration (in meta) but there is no comment explaining it. I literally found only one page in google search this predicate and that doesn't explain it either. Do someone know what these predicates are?

  1. PageOrMediaPredicate
  2. LatestVersionPredicate
  3. LanguagePredicate
  4. GeolocationPredicate

As a new Sitecore developer I don't know where to find explanations for such thing, is there any developer's guide available where they have explained all libraries?

Update If I debug the query that is fetching data from cache it shows same number of results but where query.WherePageOrMediaPredicate(searchQueryModel.Site)) is called, it gives no data. searchQueryModel.Site is null in both cases, when it works and when it doesn't.

1
  • 1
    Try to decompile dll with dotPeek and you will be able to see exactly what code does. Jan 17 at 16:52

1 Answer 1

1

PageOrMediaPredicate

If you check Settings item under your SXA site root, you will find 2 fields there: Associated Media and Associated Content.

If PageOrMediaPredicate is used on your site, only items (or media) selected in those 2 fields will be returned in search results. For content items there is another requirement: they must inherit from _Searchable or _SearchableWithoutRelatedItems template.

LatestVersionPredicate

It must be the latest version of an item. From what I remember, for web database it's always true, but best check on your own.

LanguagePredicate

You pass a list of language names. Only versions of items in one of the languages are returned.

GeolocationPredicate

If I understand it correctly, it returns items which are points of interests and which are selected in Associated Content setting (see above)

2
  • Thank you for the response, it makes thing lot clearer. Can you please help me understand why everything is filtered out by using this predicate when I am taking query from cache? I cached same query which used to pass these predicates.
    – Imad
    Jan 18 at 3:10
  • I don't know that Jan 18 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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