Lucene Interlacing Search Results

74 views Asked by At

There may be posts like this on here but I'm not sure what to call this type of sorting method so searches haven't really yielded anything very useful. Mostly I've seen things about boosting terms but I don't think that will help in this case unless I can make the boosts have diminishing returns (and even that may have an issue at scale). Links to those would be appreciated if they exist.

I'm creating a module for a blog page in Sitecore that will display a small number of related blog posts. These blog posts should be based on the authors of the blog. This is relatively easy to do when there is one author however the requirements given have made this difficult when there are multiple. The requirements state that when there is more than one author, the blogs that show should alternate between each author's most recent post with no duplicates. An example would be this:

In this scenario a blog post's order of posting is represented by the letter (post A was posted before post B).

Blog post Y has 3 authors whose names are Jack, Jill and Jim.

Jack has posted another blog post X.

Jill has another post that is more recent than Y called Z as well as older posts N (done with Jim) and M.

Jim has posted blog posts N (done with Jill), O and L.

The order that these posts should show up based on the scenario is as follows: X N O M L

Note that when Jim's first post is supposed to be used N is not used because it is already in our result list when Jill's post was shown.

It's looks like I'm potentially going to need to do a query per author in order to deal with this or query for posts filtering on the authors, sorting by date and then manually dealing with the resulting list. The first way results in multiple queries though and the second way potentially can involve iterating over the entire index.

I also thought I could do the following: Store an int field called related author sort. Make that equal to the number of blogs written by the author with a post date before the current blog (may take a while to process that). Do an inverted sort on that.

The point of inverting the number would be so that field wouldn't need to be updated whenever a new blog was added. That falls apart though since there are multiple authors so I would need multiple author sort values.

Note: doing it this way will end up bringing authors with more blogs to the top rather than what I want.

0

There are 0 answers