[Xapian-discuss] Results Filtering

Olly Betts olly at survex.com
Thu Apr 27 12:37:32 BST 2006


On Thu, Apr 27, 2006 at 05:46:11PM +1200, Georgina Allbrook wrote:
> I am managing to have some success getting omega to work on our website
> but have a couple of questions.  Is it possible to restrict the results
> returned from a query to a particular hostname or subsite?

Hostname is certainly possible.  You can't arbitrarily restrict to "any
file under www.example.com/foo/" without modifying omindex, but you
can filter by the "baseurl" specified to a particular run of omindex.

> Reading the docs it would seem that I need to use boolean filter terms,
> or maybe match decider.

Boolean filter terms are better for this.

> Ideally I would have a couple of radio buttons, search the whole site,
> or just a subsite.  But I don't seem to be able to make it work.  Is
> this something that is difficult to do, or do I not quite understand the
> docs?

It's pretty easy, but the documentation seems to lack a worked example.
I'll write one here and put it in the docs:

For radiobuttons, filtering by hostname:

<INPUT TYPE="radio" NAME="B" VALUE="Hwww.example.com" $if{$find{$cgilist{B},Hwww.example.com},CHECKED}> The Main Website<br>
<INPUT TYPE="radio" NAME="B" VALUE="Hwidgets.example.com" $if{$find{$cgilist{B},Hwidgets.example.com},CHECKED}> Our Widgets Collection<br>

The expression $find{$cgilist{B},TERM} tests if there's a B parameter
with value TERM, allowing for the fact there may be multiple such
parameters (e.g. if you allow filtering by hostname or mimetype).

If you just want to show the hostnames, you can use the OmegaScript
$map command like so, which is convenient if there are a lot of values:

$map{$split{www.example.com widgets.example.com sales.example.com},
<INPUT TYPE="radio" NAME="B" VALUE="H$_" $if{$find{$cgilist{B},H$_},CHECKED}> $_<br>
}

[You should really be able to get a list of all terms with a specified
prefix in OmegaScript and then you could use the above to produce a
list which is automatically up-to-date.  I'll look at adding such a
command as it should be pretty trivial to implement.]

You can produce a drop-down selector instead:

<SELECT NAME="B">
<OPTION VALUE="Hwww.example.com" $if{$find{$cgilist{B},Hwww.example.com},SELECTED}>The Main Website</OPTION>
<OPTION VALUE="Hwidgets.example.com" $if{$find{$cgilist{B},Hwidgets.example.com},SELECTED}>Our Widgets Collection</OPTION>
</SELECT>

Cheers,
    Olly



More information about the Xapian-discuss mailing list