Lucene Interlacing Search Results - asp.net

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.

Related

WordPress query multiple post_types/categories with weighted results

For a WordPress project I'm looking for a better solution to this problem:
The query should get a set of different post_types and taxonomies (like categories), based on the site visitors choice. For example, the user want to get results from normal posts, but also products (from WooCommerce) and other post_types like events and news (both separate post_types. The tricky part is, that the user wants to assign a weight factor to each. So if they select like posts = 1, products = 3, news = 4, they should get a number of posts, three times more products and 4 times more news.
Next step will be to include categories, also with the weight factor, which will make it even more complex, because for posts, I need to query another taxonomy than for products.
The only way I found to solve this, is to run a separate query for each post_type, like fetching 10 items from posts, 30 items from products and 40 from news, to match the weight factors, then combine the results. But this will not scale very well when I need pagination (for example, I want to show 50 entries on the first page, next 50 on second page).
I thought about collecting these single queries into a temporary table, but such a table will be available for the current session only, so it won't help with the pagination (as the temporary table would no longer exist, when the second page is shown).
Does anybody have an idea, how I could approach this task? I would like it according to the WordPress coding standards, so I would like to use WP_Query and the provided filters, because the site is also using geolocating and WPML for translation, so I really would like to avoid writing a low-level query where I have to include all these manually.
I'm not looking for a final solution, just want to collect some ideas.

Trying to build a 'random text' WordPress plugin. No idea where to start

Here’s what I’ve done in a spreadsheet:
I’ve assigned people to one or more categories (ie. male, female, tall, short)
I’ve assigned weights to these people (ie. 200 lbs, 120 lbs, 300 lbs)
I’ve assigned names to these people (ie. John, Jane, Bill)
Here’s what I need to do in a plugin:
Find some way to get my data into it (maybe through an admin interface, or via my spreadsheet)
Filter results by one or more categories (ie. only male; only tall + female, etc)
From those filtered results, pull 2 or 3 people (as many as I can fit) whose combined weights equal X or less
Display the names of those 2 or 3 people as a list to front-end users
At the press of a button, randomly generate another 2 or 3 person team
I don’t mind getting my hands dirty, but I don't know where to begin. If you guys could give me any advice, best practices, code to get me started, or names of plugins that already do this, etc, I’d really appreciate it.
Also, if I’m biting off too much for a complete noob, feel free to let me know. Because if it comes down to it, I’ll just create the teams manually and throw them into a random text plugin, or something.
This depends heavily on what format it's in presently. If it's in a spreadsheet, you can import it pretty easily by saving as a CSV and processing it with fgetscsv
Assuming this is going into MySQL (as most WP plugins do), this is just a SQL query (ie WHERE wp_custom_person_record_weight > 100 AND wp_custom_person_record_name != 'Bill'
Same as #2 but with a JOIN and a SUM and a WHERE query against that sum.
This is the same SQL query, if you call it through mysqli_query you'll get an array back that you can output on the page
Random records can be gleaned a number of ways, either by going through a limit of X,2 where X is a randomly generated number between 0 and the # of records or through MySQL itself (although that is not recommended for performance reasons).

Yahoo pipes: How to output the difference between two feeds?

How can one output the difference between two feeds in Yahoo Pipes?
That is to say, I want all the posts from module A which do not occur in module B (filtered by title).
I've found how to get the set union using the Unique operator, but I can't find an obvious operator for getting the set difference.
Example
Let's say a newspaper website publishes two feeds, FrontPage.rss and Politics.rss, and that the most interesting items from the politics feed are also published on the front page feed among other items. We want to subscribe to both feeds separately, and we don't want receive politics articles in our front page feed, because we're already reading them elsewhere. We can subscribe directly to the politics feed, but for the front page feed we actually want all the items from FrontPage.rss except those which also occur in Politics.rss. That is, the set difference of FrontPage and Politics (also known as the relative complement of Politics in FrontPage).
In the operators section you should be able to use the "unique" module to filter based on a unique identifier such as a url.
Put both feeds through a "Union" module, then put the output through a "Unique" module.

Website Layout Statistics

I have a client who has suggested laying out a long list of categories in a custom order. The order is to be decided by them based on product items they sell the most etc.
I tend to disagree and feel that people browsing the internet prefer to search lists of categories that are in alphabetical order or sorted by something they can take reference of such as a date.
I would like to know others thoughts on this and it would be appreciated if anyone could point me in the direction of any open source surveys that have been taken in this area.
Thanks
Ben
What a silly stance to take regarding a simple customer request. Allow for both orderings, and other ones too. There is no survey that will demonstrate that the client is wrong as they are - by definition - correct.
Code that allows for different orderings has greater utility anyway, and real user data will be able to show them which - if either - should be the default.

Drupal 6 Views: Constraining fields which are not the "primary" node

I'm making a custom list of nodes and their comments. I'd like to be able to both constrain the number of nodes (easy: Items per page refers to nodes in this case) but also constrain the number of comments displayed per node (e.g. the 5 most recent):
Node number one
Comment 1-3
Comment 1-2
Comment 1-1
Node number two
Comment 2-7
Comment 2-6
Comment 2-5
Comment 2-4
Comment 2-3
Node number three
So Node number one has three comments. Fine. And Node number three has no comments. Also fine. But Node number two has seven comments; but I only want to show the most recent five.
Is there any way of doing this in Views? It's easy enough to make a view which has the comments in and an argument to provide the node id, were it possible to include such a view inside another view, for example.
I'm brand new to Drupal, so apologies if it's an obvious question. I've googled it, but it's hard to know if you're googling the right thing when you've just started.
Any suggestions appreciated!
Rob
according to the views developper here http://drupal.org/node/353872
is almost impossible to do in just one query, and as such is something Views can't support.
however, these modules might be interesting for you:
Views Group By or Views Attach and might be a step closer to the solution.
I can't think of an easy way to do this in views alone. You might need to do a combination of views and a little custom code to get the final result :/

Resources