Hi all, 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? For some subsites I have a separate database, but for many subsites we don't create separate databases. In english I think the query might be something like: url starts with www.mysite.com/bob/ and (word1 and words). Reading the docs it would seem that I need to use boolean filter terms, or maybe match decider. 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? Thanks Georgina. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Georgina Allbrook WebTeam : ITS Division : University of Waikato http://phonebook.waikato.ac.nz/dept/WWTE.shtml ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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? > For some subsites I have a separate database, but for many subsites we > don't create separate databases. > > In english I think the query might be something like: url starts with > www.mysite.com/bob/ and (word1 and words). > > Reading the docs it would seem that I need to use boolean filter terms, > or maybe match decider.Just a boolean filter term will do. When you're indexing with omindex, then you're probably doing something like: ---------------------------------------------------------------------- $ omindex -p --db /my/db/path --url 'http://www.mysite.com/bob' \ /var/www/www.mysite.com/bob ---------------------------------------------------------------------- in which case omindex will generate a boolean term Pbob for all documents created during that index. You then need to have B=Pbob as an http parameter to omega.cgi when searching, so something like: ---------------------------------------------------------------------- <select name='B'> <option vlaue=''>Entire site</option> <option value='Pbob'>Bob's bits</option> <option value='Pcorporate'>Corporate information</option> <option value='Pcheese'>History of cheese</option> </select> ---------------------------------------------------------------------- should do what you need - I haven't used this recently, but that's one of the reasons the subsite concept was added to omega. Cheers, James -- /--------------------------------------------------------------------------\ James Aylett xapian.org james@tartarus.org uncertaintydivision.org
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