web analytics

Search upgraded (yet again)

Written By: - Date published: 12:47 am, March 15th, 2010 - 4 comments
Categories: admin - Tags:

My absence this weekend from moderation and posts has partially been because of going to the excellent Fabian seminar today. However it has largely been due to trying to get a workable search system running.

One that didn’t bring the whole server crashing around my ears every few months and cut the issue of everyone having to stop receiving data for up to a minute when someone used search. One that allowed comments to be accessed as easily as posts, which Search Unleashed achieved (which eventually failed because the re-index took too long). It looks like it is finally working correctly, but I’d like feedback on any errors that show up.

For the technically minded, this is running on the Sphinx search engine with the WordPress Sphinx Search Plugin, and some custom coding in the search sidebar and search page template for our new theme. It runs a delta update for changed items every 5 minutes, and a complete rebuild at 0300.

This is the third time I’ve attempted to get this system running. Each of the previous attempts have been stymied by sphinx disliking our constrained memory during peak hours. But we’ve bumped the RAM up, and it also turns out that there were some conflicting permission issues (grrr) when running the cron jobs with an active website.

Normally I’d have consigned something as annoying to configure as this to the dustbin, but the engine is blindingly fast and perfect for our scaling needs with nearly 5000 posts and 150,000 comments currently onsite. This is expected to keep rising at rates similar or higher than have been the case so far.

Sphinx can reindex our entire database in about 30 seconds (whereas Search Unleashed required hours), and will do the delta every 5 minutes in well under a second. Almost all of the delay in presenting the search result is from assembling the display rather than the search. It is a seriously good engine and has been (so far) worth the effort.

The user interface is a little primitive at present and I also need to store and get your user selected advanced settings in your cookies. But it is good enough to look for loading problems over this week. It has a number of options that will be useful for advanced searching, especially for authors like r0b…

Sphinx extended queries syntax allows the following special operators to be used:

  • AND: hello&world hello world
  • OR: hello | world
  • NOT: hello -world or hello !world
  • field search operator: @title hello @body world
  • phrase search operator: “hello world”
  • proximity search operator: “hello world”~10

Here’s an example query which uses all these operators:
“hello world” @title “example program”~5 @body python -(php|perl)

More information about extended syntax you can find at Sphinx.

The following field operators are available:

  • @title – search in post or page title
  • @author – search in post, page, comment author (still a bit flakey)
  • @body – search in post, page, comment body
  • @category – search search in blog categories

For instance, I tested such things as lprent&fabian lprent fabian, pigs-flying, and (supershitty|super-city|super city|supercity)& franklin.

Using the author you can search for f*ck @author robinsod (that allows you to exclude the people swearing at him).

If you use the advanced and turn pages and comments off, you can resolve a long-standing argument.

  • @title “helen clark” and @title “john key” will respectively tell you how often each was mentioned in the title of a post.
  • @body “helen clark” and @body “john key” will respectively tell you how often each was mentioned in the body of a post.

If I see that argument again…..

The time to run a search seems to be roughly the same regardless of how complex I make the query.

Anyway, let me know if you find any issues using the form in contact. I’ll be keeping an eye on it for the next 3 or 4 days for performance issues.

Hopefully I’ll now have more time  to write posts and tackle the minor teething issues like the misbehaving Contribute Past captcha, and less time trying to maintain a fragile search mechanism that was slowly fading under increased loads.

BTW: For those of you who were at the Fabian seminar today. I was paying attention to the panel and discussion. But I was also coding during the seminar. This had been bugging me most of the weekend to the point where I had to go to the seminar, tether the iPhone to the net, and finish the damn search page interface.

Update: Been through the site settings for the first time since it last had a server move. You’ll see a significant improvement in performance in the search, and probably in just reading the site.

Update: Found a couple of errors in the post, which you will see corrected with the original in strikeout. There are a number of enhancements to the system (like @author). I added some additional examples while testing.

But I was paying attention to the seminar as well

4 comments on “Search upgraded (yet again) ”

  1. lprent 1

    Ummm, one thing it misses is the comment author name…. and post author name..

    Ok that is a problem in the query, which I’ll adjust in the sphinx.conf tomorrow sometime

    • mummybot 1.1

      Good on ya mate! 😉

      • lprent 1.1.1

        Did a burst of database optimization tonight as well. I’m pretty sure that the site will be significantly faster for reading and probably the same or slightly better for writing.

        Sphinx was loading down the system (as well as some of the other queries) so I tuned up a couple of tables with indexes based on what was showing in the slow query log. Then I tuned mysql to use more of the memory/disk/cpu tradeoff. Then did some tweaks to the php settings based on its logs.

        I’d better give up some of these late night sessions.

      • lprent 1.1.2

        Just while I remember, the HTML ins and del need some css coloring and decoration. del should be coloured, and the insertions should be a different colour.

Recent Comments

Recent Posts

  • Celebrating the Entry Into Force of the Treaty on the Prohibition of Nuclear Weapons
    [Opening comments, welcome and thank you to Auckland University etc] It is a great pleasure to be here this afternoon to celebrate such an historic occasion - the entry into force of the Treaty on the Prohibition of Nuclear Weapons. This is a moment many feared would never come, but ...
    BeehiveBy beehive.govt.nz
    22 hours ago
  • Supporting disabled people to stay connected
    The Government is providing $3 million in one-off seed funding to help disabled people around New Zealand stay connected and access support in their communities, Minister for Disability Issues, Carmel Sepuloni announced today. The funding will allow disability service providers to develop digital and community-based solutions over the next two ...
    BeehiveBy beehive.govt.nz
    1 day ago
  • Voluntary saliva testing offered to quarantine workers from Monday
    Border workers in quarantine facilities will be offered voluntary daily COVID-19 saliva tests in addition to their regular weekly testing, COVID-19 Response Minister Chris Hipkins said today. This additional option will be rolled out at the Jet Park Quarantine facility in Auckland starting on Monday 25 January, and then to ...
    BeehiveBy beehive.govt.nz
    1 day ago
  • Next steps in firearms buy-back
    The next steps in the Government’s ambitious firearms reform programme to include a three-month buy-back have been announced by Police Minister Poto Williams today.  “The last buy-back and amnesty was unprecedented for New Zealand and was successful in collecting 60,297 firearms, modifying a further 5,630 firearms, and collecting 299,837 prohibited ...
    BeehiveBy beehive.govt.nz
    1 day ago
  • New Public Housing Plan announced
    The Government has released its Public Housing Plan 2021-2024 which outlines the intention of where 8,000 additional public and transitional housing places announced in Budget 2020, will go. “The Government is committed to continuing its public house build programme at pace and scale. The extra 8,000 homes – 6000 public ...
    BeehiveBy beehive.govt.nz
    2 days ago
  • Prime Minister congratulates President Joe Biden on his inauguration
    Prime Minister Jacinda Ardern has congratulated President Joe Biden on his inauguration as the 46th President of the United States of America. “I look forward to building a close relationship with President Biden and working with him on issues that matter to both our countries,” Jacinda Ardern said. “New Zealand ...
    BeehiveBy beehive.govt.nz
    2 days ago
  • Jobs for Nature funding will create training and employment opportunities
    A major investment to tackle wilding pines in Mt Richmond will create jobs and help protect the area’s unique ecosystems, Biosecurity Minister Damien O’Connor says. The Mt Richmond Forest Park has unique ecosystems developed on mineral-rich geology, including taonga plant species found nowhere else in the country. “These special plant ...
    BeehiveBy beehive.govt.nz
    4 days ago
  • Pre-departure testing extended to all passengers to New Zealand
    To further protect New Zealand from COVID-19, the Government is extending pre-departure testing to all passengers to New Zealand except from Australia, Antarctica and most Pacific Islands, COVID-19 Response Minister Chris Hipkins said today. “The change will come into force for all flights arriving in New Zealand after 11:59pm (NZT) on Monday ...
    BeehiveBy beehive.govt.nz
    4 days ago
  • Bay Cadets learn skills to protect environment
    Bay Conservation Cadets launched with first intake Supported with $3.5 million grant Part of $1.245b Jobs for Nature programme to accelerate recover from Covid Cadets will learn skills to protect and enhance environment Environment Minister David Parker today welcomed the first intake of cadets at the launch of the Bay ...
    BeehiveBy beehive.govt.nz
    5 days ago
  • Cook Islanders to resume travel to New Zealand
    The Prime Minister of New Zealand Jacinda Ardern and the Prime Minister of the Cook Islands Mark Brown have announced passengers from the Cook Islands can resume quarantine-free travel into New Zealand from 21 January, enabling access to essential services such as health. “Following confirmation of the Cook Islands’ COVID ...
    BeehiveBy beehive.govt.nz
    1 week ago
  • Supporting communities and landowners to grow employment opportunities
    Jobs for Nature funding is being made available to conservation groups and landowners to employ staff and contractors in a move aimed at boosting local biodiversity-focused projects, Conservation Minister Kiritapu Allan has announced. It is estimated some 400-plus jobs will be created with employment opportunities in ecology, restoration, trapping, ...
    BeehiveBy beehive.govt.nz
    1 week ago
  • Border exception for some returning international tertiary students
    The Government has approved an exception class for 1000 international tertiary students, degree level and above, who began their study in New Zealand but were caught offshore when border restrictions began. The exception will allow students to return to New Zealand in stages from April 2021. “Our top priority continues ...
    BeehiveBy beehive.govt.nz
    1 week ago
  • Tiwai deal gives time for managed transition
    Today’s deal between Meridian and Rio Tinto for the Tiwai smelter to remain open another four years provides time for a managed transition for Southland. “The deal provides welcome certainty to the Southland community by protecting jobs and incomes as the region plans for the future. The Government is committed ...
    BeehiveBy beehive.govt.nz
    1 week ago
  • New member for APEC Business Advisory Council
    Prime Minister Jacinda Ardern has appointed Anna Curzon to the APEC Business Advisory Council (ABAC). The leader of each APEC economy appoints three private sector representatives to ABAC. ABAC provides advice to leaders annually on business priorities. “ABAC helps ensure that APEC’s work programme is informed by business community perspectives ...
    BeehiveBy beehive.govt.nz
    1 week ago
  • Govt’s careful economic management recognised
    The Government’s prudent fiscal management and strong policy programme in the face of the COVID-19 global pandemic have been acknowledged by the credit rating agency Fitch. Fitch has today affirmed New Zealand’s local currency rating at AA+ with a stable outlook and foreign currency rating at AA with a positive ...
    BeehiveBy beehive.govt.nz
    1 week ago
  • Additional actions to keep COVID-19 out of NZ
    The Government is putting in place a suite of additional actions to protect New Zealand from COVID-19, including new emerging variants, COVID-19 Response Minister Chris Hipkins said today. “Given the high rates of infection in many countries and evidence of the global spread of more transmissible variants, it’s clear that ...
    BeehiveBy beehive.govt.nz
    2 weeks ago
  • 19 projects will clean up and protect waterways
    $36 million of Government funding alongside councils and others for 19 projects Investment will clean up and protect waterways and create local jobs Boots on the ground expected in Q2 of 2021 Funding part of the Jobs for Nature policy package A package of 19 projects will help clean up ...
    BeehiveBy beehive.govt.nz
    2 weeks ago
  • New Zealand Government acknowledges 175th anniversary of Battle of Ruapekapeka
    The commemoration of the 175th anniversary of the Battle of Ruapekapeka represents an opportunity for all New Zealanders to reflect on the role these conflicts have had in creating our modern nation, says Associate Minister for Arts, Culture and Heritage Kiri Allan. “The Battle at Te Ruapekapeka Pā, which took ...
    BeehiveBy beehive.govt.nz
    2 weeks ago
  • Better care for babies with tongue-tie
    Babies born with tongue-tie will be assessed and treated consistently under new guidelines released by the Ministry of Health, Associate Minister of Health Dr Ayesha Verrall announced today. Around 5% to 10% of babies are born with a tongue-tie, or ankyloglossia, in New Zealand each year. At least half can ...
    BeehiveBy beehive.govt.nz
    3 weeks ago