Searching a Playa field, ordering results based on the search term
Hey Low - have a site with articles and one of the fields is Playa to set the author of a particular article.
In testing, we have 1 author who has contributed around 300 articles but when we search on his name, we only get around 100 results. We've already weighted the author field to 3, is there anything else we're missing?
Also, would it be possible to make articles by the searched for author appear at the top of search results?
Replies
Low 12 Nov 2014 11:19
This kind of depends on how/when Playa stores its searchable data in the exp_channel_data table, and therefore in the search index.
What's the template code you're using? You can use http://pastie.org/ or http://pastebin.com/ for large chunks of code.
You could order the search results by the playa field, but just ordering by author sounds tricky; when do you know when you're searching for an author instead of just content of the article?
stevieg_83 12 Nov 2014 11:24
This is the search form https://gist.github.com/5538eba081b20... and the results https://gist.github.com/24de770505db5...
Yeah, I thought as much on ordering by author. I did query the client because they can hit an author's profile to see all of their articles regardless.
Low 12 Nov 2014 11:29
As an idea, you can have the same form target just the Authors in a separate Results tag and link to them, too.
Since you're just searching by Keywords, and your mismatch concerns a Playa field, it could be that the Playa fields themselves aren't up to date. You could check that by running a SQL query on the fields themselves to see what their actual content is.
stevieg_83 12 Nov 2014 11:32
That's a point actually. The previous devs had this field as a native EE relationships field and obviously the search didn't work. Since converting to Playa, we've had to manually save some entries to see the author update properly.
I guess that's why the results would be off.
Low 12 Nov 2014 11:38
Yep. I think I saw a script to update those fields on EESE, recently. That would be needed to update the Playa fields.
stevieg_83 12 Nov 2014 11:52
Thanks Low.