Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Was there a change in what client.Search() returns?

$
0
0

We have a job that finds a particular type of pages, updates and publishes them. If publishing fails a draft is saved.

This is our code to retrieve a page that needs to be updated

return _client.Search<AuthorPage>()
    .Filter(x => x.IsDeleted.Match(false))
    .Filter(x => x.SearchSubsection().Match("Authors"))
    .Filter(x => x.Email.MatchCaseInsensitive(email))
    .GetContentResult()
    .Where(x => !x.IsExpired())
    .OrderByDescending(x => x.Status)
    .FirstOrDefault()

We were Ordering by status because we were getting both a published version and a draft; but if there was a draft we wanted to update this version and to try publish it.

And no matter how many times a job would fail to publish a page, it should try to update the same draft. That is how it worked in CMS 11.

Now in CMS 12 under some Author pages we are seeing a lot of drafts and have noticed that the same query even before the FirstOrDefault() already returns only one result - the published version (unless there is no published version and only a draft, then this one is returned). Then the job tries to update it but if it fails it creates a new draft, and the next time it fails it creates yet another draft and so on. Eventually when a page is published we end up with a lot of drafts. 

Was there some kind of change in what Search method returns? 

Is there an overload? Another method? How do we get the same result as before?


Viewing all articles
Browse latest Browse all 9076

Trending Articles