Archive for the ‘Technology’ Category

Xapian search – acts_as_xapian tip (II)

Saturday, September 20th, 2008

Further to my first post on using acts_as_xapian, I have been trying to make xapian work with pagination and association proxies properly

class Lesson < ActiveRecord::Base
# Index user_id as a term in xapian

    belongs_to :user
    def self.find_with_xapian(search_term, options={})
      ActsAsXapian::Search.new([self], search_term, options).results.collect{|x| x[:model]}
    end
end

class User < ActiveRecord::Base
    has_many :lessons do  #Extend this association
      # Override the method in lessons
      def self.find_with_xapian(search_term, options={})
        ActsAsXapian::Search.new([proxy_reflection.klass],
          "{proxy_reflection.primary_key_name}:#{proxy_owner.id}  #{search_term}", options)
        .results.collect{|x| x[:model]}
      end
    end
end

This will ensure that current_user.locations.find_with_xapian will find the correct number of locations, enabling us to work with pagination, etc. What’s left to do is to get the Search object out so that we can get matches_estimated out. I’ll leave out for next time.

This post was brought to you from Software Freedom Day, New Zealand.

Search as Locator Entry

Tuesday, September 16th, 2008

Jakob Nielsen has just written an article on location finders. The article outlines some behaviour changes of users in finding locations over the years.

The lastest research has found…

It’s still striking that 73% of users went to a search engine (mainly Google) when we asked them to find a nearby location for a specific company. Only 13% went straight to that company’s own website, while the remaining 13% went to a dedicated mapping service.

Given this changing behavior, we now have guidelines for search engine optimization (SEO) for the locator.

We’ve focused on making ZoomIn SEO friendly from day one so that businesses can be easily found. We constantly tune our system to ensure that we’re at the top the list for a result.

This re-inforces the need for businesses to make sure that their locations are being “found”, using ZoomIn is a good way to make sure that happens!

Runtime page optimiser now live

Tuesday, September 16th, 2008




Runtime Page Optimiser (RPO) is now out of beta, the team from www.actionthis.com have release the automagic web optimisation tool for IIS based sites. RPO is certified for ASP.NET 2.0 and MOSS/SharePoint 2007 intranet and internet sites.

Here’s a list of benefits:





But wait there’s still more, the team are going to release shortly an online webpage optimisation report tool based on AOL Page test.

Congrats to the ActionThis team and I’m looking forward for future improvements.

Xapian search – acts_as_xapian tip

Thursday, September 11th, 2008

We use xapian as our offline indexing solution here at ProjectX. Recently, Francis Irving from mySociety has started a fantastic Rails plugin, acts_as_xapian. I’ll leave the introductions to the aforementioned pages. Suffice to say that it is quite easy to install, and it utilizes all the power of Xapian in a very smooth way.

One thing I have not been able to crack is to utilize association proxies on searches. Locomotivation has a solution using named_scope, but that approach removes all ordering, in addition to issuing one more unnecessary SQL statement.

class Lesson < ActiveRecord::Base
    named_scope :find_with_xapian, lambda { |*args| {:conditions => ["lessons.id in (?)", ActsAsXapian::Search.new([Lesson], args.to_s).results.collect{|x| x[:model].id}]}}
end

But if we do this instead, we can now do association proxies

class Lesson < ActiveRecord::Base
    def self.find_with_xapian(search_term, options={})
      ActsAsXapian::Search.new([self], search_term, options).results.collect{|x| x[:model]}
    end
end

current_user.lessons.find_with_xapian "something"

That would automatically scope and return lessons that belong to the current user only. Awesome!

Update: The code is not showing quite as nicely. I have pasted the same code in Pastie – http://pastie.org/270114

ProjectX smarts powers Te Papa's Ourspace – The Wall

Monday, September 1st, 2008




A while back, we did some work for Gibson groups for the Te Papa Ourspace project. We created a special version of the ZoomIn Map API for a special part of the project called the Wall.

Its nice to finally see it action!