Tags:
create new tag
view all tags

Question

What Search Method Should I Use?

Environment

TWiki version: TWikiRelease04x02x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Windows XP
Web server: Apache 2.2.4
Perl version: Perl 5.8.8
Client OS: Windows XP
Web Browser: IE Version 6
Categories: Search

What search method should I be using when I'm looking for specific values in a form?

I am confused on the proper way to search for topics that contain a specific form and a specific value for one of the fields on the form. There seems to be many options to do this. Those options seem to be:

  • METASEARCH
  • QuerySearch
  • META
  • SEARCH

Some of these example worked for me (I'm not sure why sometimes) and other examples did not.

My goal was to find all topics in the Sandbox web that have the form BeatlesFanForm and have the field FavoriteBeatle equal to Ringo. Which option is best and will most likely survive any future upgrades of TWiki? My attempt at METASEARCH worked.

METASEARCH Example

I typed this:

| *Entry* | *Fan Name* | *Favorite Beatle* | *Super Fan* | *Fan Story* |
%METASEARCH{type="field" name="FavoriteBeatle" value="Ringo" web="%WEB%" format="|  [[$topic][ %PUBURL%/%TWIKIWEB%/TWikiDocGraphics/viewtopic.gif ]]  | $formfield(FanName) | $formfield(FavoriteBeatle) | $formfield(SuperFan) | $formfield(FanStory) |"}%

and I got that:

Search1.GIF

I did this in the Sandbox Web. These were my expected results. I couldn't seem to figure out how to specify the exact form I wanted. What would happen if another form besides BeatlesFanForm contained a field called FavoriteBeatle? I assume I'd get those results as well if I can't specify the form name. Is this the way more experienced TWiki users would do it?

QuerySearch Example

I read the topic QuerySearch. This seemed to me to be the best way to do it. This felt a little more intuitive. Here I was able to specify a form.

I typed this:

| *Entry* | *Fan Name* | *Favorite Beatle* | *Super Fan* | *Fan Story* |
%SEARCH{"web='Sandbox' BeatlesFanForm.FavoriteBeatle = 'Ringo'" type="query" format="|  [[$topic][ %PUBURL%/%TWIKIWEB%/TWikiDocGraphics/viewtopic.gif ]]  | $formfield(FanName) | $formfield(FavoriteBeatle) | $formfield(SuperFan) | $formfield(FanStory) |"}%

and I got that:

Search2.GIF

Query Search did not seem to work for me at all. I'm not sure If I simply have a syntax error. Did I do this correctly?

META Example

I got confused here if I should use META by itself or if I have to embed it into a SEARCH. I put into a search based on some other example I saw.

I type this:

| *Entry* | *Fan Name* | *Favorite Beatle* | *Super Fan* | *Fan Story* |
%SEARCH{ "META\:FIELD.*?FavoriteBeatle.*?Ringo" regex="on" nosearch="on" format="|  [[$topic][ %PUBURL%/%TWIKIWEB%/TWikiDocGraphics/viewtopic.gif ]]  | $formfield(FanName) | $formfield(FavoriteBeatle) | $formfield(SuperFan) | $formfield(FanStory) |"}%

and I got that:

Search3.GIF

This worked for me but I have to admit I don't understand why. I don't understand the backslash between META and FIELD. When I tried this without it the results returned back the topic I was working in for some reason where as with the slash it did not (which is good). I don't really understand what the .*? is all about. Not sure what's going on.

SEARCH Example

Lastly, I saw some examples that used plain old search.

I typed this:

| *Entry* | *Fan Name* | *Favorite Beatle* | *Super Fan* | *Fan Story* |
%SEARCH{"[F]avoriteBeatle.*value=.*[R]ingo" regex="on" type="regex" scope="text" format="|  [[$topic][ %PUBURL%/%TWIKIWEB%/TWikiDocGraphics/viewtopic.gif ]]  | $formfield(FanName) | $formfield(FavoriteBeatle) | $formfield(SuperFan) | $formfield(FanStory) |"}%

and I got that:

Search5.GIF

I do not understand the purpose over brackets on the first letter of the field name and value. I don't think I'm doing the syntax correctly because as you can tell the results didn't come out correctly. Sorry for the long support topic. Could someone tell me what search I should be using and help with with these examples. Thank you very much!

-- MichaelCarter - 24 May 2008

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

I have the same questions. I can get these constructs to work but I do not understand the brackets on the SEARCH terms. And, I do not understand the *? on the META\Field SEARCH.

-- JohnGee - 09 Jun 2008

My recommendation is to use QuerySearch. Unfortunately the syntax of your query search is up the spout. You wrote:

| *Entry* | *Fan Name* | *Favorite Beatle* | *Super Fan* | *Fan Story* |
%SEARCH{"web='Sandbox' BeatlesFanForm.FavoriteBeatle = 'Ringo'" type="query" format="|  [[$topic][ %PUBURL%/%TWIKIWEB%/TWikiDocGraphics/viewtopic.gif ]]  | $formfield(FanName) | $formfield(FavoriteBeatle) | $formfield(SuperFan) | $formfield(FanStory) |"}%
You should have written:
%SEARCH{"BeatlesFanForm.FavoriteBeatle='Ringo'" web="Sandbox" type="query" format="|  ...
or more simply
%SEARCH{"FavoriteBeatle='Ringo'" web="Sandbox" type="query" format="|  ...
Query search obeys all the normal parameters for specifying the search scope, which includes the webs and topics to search.

-- CrawfordCurrie - 13 Jun 2008

Crawford thank you very much for the help. I was able to get query search working the way I wanted. I was struggling with the syntax and what it means but I think I got it now. I do have another search question for everyone. Here is what I would like to accomplish.

  1. Perform a search that will return all topics from the Main web.
  2. From the results I want to show just those topics where the $createusername equals "JoeUser".

I have played around with nested searches, $pattern, and a few other things to no avail. I specifically want the user who first created the topic not the author which simply returns the last person who updated the topic. Thanks again for all your help. The TWiki application has been extremely useful for my team.

-- MichaelCarter - 05 Aug 2008

The only way I imagine you could do this search would be to use an IfStatements in the search result format. At least I think it might... It would look something like (untried):

%SEARCH{"FavoriteBeatle='Ringo'" web="Sandbox" type="query" format="percntIF{\"$createusername = 'JoeUser'\" then=\"|  $topic]  | $formfield(FanName) | $formfield(FavoriteBeatle) | $formfield(SuperFan) | $formfield(FanStory) |\" else=\" \"}percnt" }%

-- LynnwoodBrown - 05 Aug 2008

I agree, this looks like a job for FormattedSearch (that format line needs to use $percnt BTW).

With $IF:

%SEARCH{
  "Sean"
  web="Sandbox"
  type="regex"
  nonoise="on"
  format="$percntIF{\"$createusername = 'SeanCMorgan'\" then=\"%BB% [[$web.$topic]]: $createdate\" else=\"<nop>\"}$percnt"
}%

Renders like this: IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.CalendarPluginWithJSCalendarContrib: 2007-06-11 - 04:07" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.CarteleraIspee: 2005-03-16 - 03:39" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.ChangeRequest1022: 2003-05-20 - 21:54" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.ComunicacionDatosSatelites: 2013-02-21 - 01:25" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.CostControl: 2002-10-25 - 03:04" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.DaveLarsonSandbox: 2013-04-23 - 20:15" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.FabBox: 2008-04-09 - 00:40" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.ForumChocolate0006: 2008-06-24 - 00:54" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.FrancisBurnsSandbox: 2008-05-27 - 01:51" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.GuiaDeConducta: 2008-06-09 - 22:33" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.HeatherHarmerSandbox: 2009-06-14 - 23:48" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.HomePageNoc: 2018-12-17 - 11:24" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.LarsEAnderssonSandbox: 2012-03-13 - 13:32" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.Lecture23May2003: 2010-12-29 - 02:20" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.LesLaCroixSandbox: 2007-11-06 - 21:58" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.MarkVainbergSandbox: 2021-02-09 - 17:19" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.MyQuestions: 2002-02-15 - 14:54" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.NewHire0009: 2008-10-22 - 19:42" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.RM_Resource_List: 2008-05-22 - 13:42" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.RM_Resource_List_Use: 2008-05-22 - 13:43" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.Scctest: 2011-02-02 - 22:25" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanCMorganParameterizedInclude: 2008-07-16 - 21:47" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanCMorganSandbox: 2008-05-27 - 21:41" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanCMorganSandboxArchive: 2008-07-16 - 15:05" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanClarkeSandbox: 2010-03-01 - 15:34" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanConnorSandbox: 2010-08-25 - 14:46" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanCordry1Sandbox: 2011-02-05 - 17:58" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanCordrySandbox: 2011-02-02 - 19:30" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanTopic: 2002-06-13 - 20:39" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeanTudorSandbox: 2014-12-02 - 17:24" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SeansSandbox: 2008-02-07 - 22:34" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.SiteMapUsingNestedSearch: 2008-05-22 - 22:18" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.TestTopic44446821: 2020-08-30 - 08:31" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.TreeOfTopicsOrWebMap: 2004-05-05 - 14:53" }: Excess operators (=) in ' = 'SeanCMorgan''
IF{ " = 'SeanCMorgan'" else="" then="
Sandbox.WebStatistics: 2019-02-18 - 08:00" }: Excess operators (=) in ' = 'SeanCMorgan''

With SpreadSheetPlugin's %IF%:

%SEARCH{
  "Sean"
  web="Sandbox"
  type="regex"
  nonoise="on"
  format="$percntCALC{$IF($EXACT($createusername,SeanCMorgan), %BB% [[$web.$topic]]: $createdate, <nop>)}$percnt"
}%

Renders like this:

-- SeanCMorgan - 06 Aug 2008

Sean you are awesome! Works perfectly. Thank you!!!

-- MichaelCarter - 07 Aug 2008

Change status to:

Topic attachments
I Attachment History Action Size Date Who Comment
GIFgif Search1.GIF r1 manage 14.7 K 2008-05-24 - 23:10 UnknownUser METASEARCH Example
GIFgif Search2.GIF r1 manage 5.8 K 2008-05-24 - 23:11 UnknownUser Query Search Example
GIFgif Search3.GIF r1 manage 14.7 K 2008-05-24 - 23:11 UnknownUser META Example
GIFgif Search5.GIF r1 manage 15.4 K 2008-05-24 - 23:12 UnknownUser SEARCH Example
Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2008-08-19 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.