Skip to main content.
home | support | download

Back to List Archive

Re: [swish-e] faceted search feature in Swish3

From: Brad Miele <brad(at)not-real.rumblefish.com>
Date: Mon Oct 12 2009 - 18:43:17 GMT
FYI, We are doing this in our new search api with Swish 2.x, see this  
demo:

http://v3.musiclicensingstore.com/API/1234567890/Search/submit_query/_/tags=1&query=water.txt

this is the debug output (Data::Dumper), but it gives you the idea, we  
are sending back various groups of tags (keywords, genre,  
moods_themes, etc...) along with the search results that we can use  
for later refinement vie property limits. The looping code looks a lot  
like what Peter has below, i could post if there is any interest.

note: the search is running on an old desktop dev box, so it isn't too  
snappy.

Brad

--------------------------------------------
Brad Miele
Director of Technology
rumblefish
107 SE Washington Street, Suite 700
Portland, OR, 97214
USA, Earth
url: http://www.rumblefish.com
email/aim: brad@rumblefish.com
vox: 503-928-6446




On Oct 12, 2009, at 11:32 AM, Peter Karman wrote:

> Thomas den Braber wrote on 10/12/2009 01:07 PM:
>> Peter,
>>
>> Great, just what I am looking for !
>> Is there also an option to limit to the x most popululair values?
>
> Not in the swish_xapian tool. swish_xapian is just a development tool
> and example of how to use libswish3 with xapian. The current
> implementation does not sort or limit the facets. That's up to the  
> user.
> swish_xapian just dumps the facets to stdout, much like it does the
> search results. It's a command-line tool anyway, so for things like  
> the
> web you'd want to use the xapian bindings directly.
>
> If you are using swish_xapian you're most likely using it for  
> indexing,
> and then searching using one of the native bindings for xapian. You  
> can
> implement the FacetFinder in the calling code of your bindings. The
> xapian feature is the MatchDecider (or if you are using the 1.1.x  
> xapian
> devel branch, the MatchSpy).
>
> As soon as I can figure out how to package SWISH::3 for cpan, there  
> will
> be a SWISH::Prog::Xapian implementation that has the faceted search
> feature using the Perl bindings of Search::Xapian. Then you'll be able
> to do something close to:
>
>  my $searcher = SWISH::Prog::Xapian::Searcher->new();
>  my $results  = $searcher->search(
>      'foo or bar',
>      facets => [qw( color )]
>  );
>  while ( my $result = $results->next ) {
>     printf("hit: %s\n", $result->swishtitle);
>  }
>  my $facets = $results->facets_for('color')->sort_by_count;
>  for my $color (@$facets) {
>      printf("color: %s (%d)\n", $color->str, $color->count);
>  }
>
> I wrote a faceted search server with Search::Xapian last week in  
> just a
> few hours. It's a very nice API, imo. My facet-building code looks  
> like:
>
>     my %facets;
>     my @facet_names = qw( color size magiclove );
>     # prop_ids are defined in swish.xml header in index dir.
>     # real code just reads that file.
>     my %prop_ids = ( color => 10, size => 11, magiclove => 12 );
>     $matches = $enq->get_mset(
>
>         $offset, $size,
>
>         sub {
>
>             my ($doc) = @_;
>
>             for my $facet (@facet_names) {
>
>
>
>                 # \003 is the SWISH_TOKENPOS_BUMPER
>
>                 # that delineates multiple values
>
>                 for my $value (
>
>                    split( /\003/, $doc->get_value( $prop_ids{$facet} )
> )
>                 )
>
>                 {
>
>                     $facets{$facet}->{$value}++;
>
>                 }
>
>             }
>
>             return $doc;
>
>         }
>
>     );
>
>
>>
>> If you look on the photo site from gettyimages.com you have  
>> something like
>> that, it shows all popular properties found in the search results  
>> and I
>> would love to have that in my application.
>
> yes, that's the idea of faceted search.
>
> -- 
> Peter Karman  .  http://peknet.com/  .  peter(at)not-real.peknet.com
> _______________________________________________
> Users mailing list
> Users@lists.swish-e.org
> http://lists.swish-e.org/listinfo/users



_______________________________________________
Users mailing list
Users@lists.swish-e.org
http://lists.swish-e.org/listinfo/users
Received on Mon Oct 12 14:43:26 2009