Question
In 20 Words or Less ..

What is the correct syntax for a
FormattedSearch that will look for all other topics with the current %TOPIC% name set as the value for a form field by the name of
TradingStrategy ?
In 20 Words and More ..
I'm having a go at developing my first
TWikiApplication. The goal is to use my TRADE web to track stock trades & keep notes about various trading strategies.
After hours of sorting for the first time thru
TWikiForms,
FormattedSearch,
TWikiMetaData,
TWikiVariables (and the like) I've finally reached exhaustion and come to grips with the fact that I'm not a programmer :-/
Thanks to tips from
LynnwoodBrown today on
TWikiIRC, I decided to give the
TopicClassificationAddOn a try. At first things seemed to be going really well there, but in the end it just wouldn't add up right. The
TopicClassificationAddOn seems to not work correctly - and the problem is a
FormattedSearch that goes bunk. See
#TopicClassificationAddonQuestion for my pondries there.
Still, I was set on developing my new
TWikiApplication, so I then set out to build my own
TWikiForms and was finally quite successful with that. I now have a working
TWikiForm +
template topic to use that form, and also a nice button on the left menu of the
KoalaSkin that can be used to automatically create new
TWikiTopics for tracking stock trades (thanks to
TWikiTemplates
Now the only thing standing in the way of my new
TWikiApplication is that I've landed back at similar problems with
FormattedSearch. Each of the different
Trading Strategies that are documented in the TRADE web already have their own
TWikiTopics. Therefore, one of the
Fields used in the form for tracking stock trades is a dropdown select that asks the user to identify which
TradingStrategy was used for this trade.
To round out the usefulness of my
TWikiApplication, I'd like to add a
FormattedSearch into the bottom of each TradingStrategy topic that will give as a result all of the
TWikiTopics with that particular strategy identified as the value for the TradingStrategy
$formfield.
These are the searches I have tried so far (each based on the example given in
FormattedSearch. Each search comes back empty, even though topics do exist with the appropriate TradingStrategy topic name as a value for the TradingStrategy
$formfield.
| *Topic:* | *Outcome of the Trade* | *Expectations Met?* |
%SEARCH{ "[T]radingStrategy.*?value=\"%TOPIC%\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OUTCOMEOFTRADE) | $formfield(EXPECTATIONSMET) |" }%
| *Topic:* | *Outcome* | *Expectations Met ?* |
%SEARCH{ "$formfield(TradingStrategy).*?value=\"%TOPIC%\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OUTCOMEOFTRADE) | $formfield(EXPECTATIONSMET) |" }%
| *Topic:* | *Outcome* | *Expectations Met ?* |
%SEARCH{ "[T]radingStrategy.*?value=\"[C]overedCall\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OUTCOMEOFTRADE) | $formfield(EXPECTATIONSMET) |" }%

I'm beginning to wonder if there's not a deeper problem here, either with the TWiki code on my OS, or with the
Search.pm or with something else ?
Another question regarding problem with searches in TopicClassificationAddOn
I've spent hours on this and I just can't figure it out. Granted, this is my first bold leap into
TWikiForms,
FormattedSearch, etc.
After installing the
TopicClassificationAddOn and creating some new TopicTypes, the
View other TopicTypes dropdown in TopicTypeMaster still contains only the original entries :
Select .., ReferenceTopic, and SubjectArea
I have manually added my new TopicTypes to the table in TopicType - but still, the
FormattedSearch in TopicTypeMaster only comes back with the results that were delivered out of the box.
Equally as frustrating, other attempts at a
FormattedSearch based off of the
FormattedSearch example also do not work :-/
Where to begin ?
Environment
--
KeithHelfrich - 19 Jul 2005
Answer
Your third search statement seems to be on the right track. Try this out:
%SEARCH{"[T]radingStrategy.*value\=.*CoveredCall" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | etc
This is predicated on the TWikiForm being properly defined and attached to the topic.
I've got quite a few applications like this. They are great once you've got them working :-). My first one took me hours to get right as I tried to get my head around forms and templates, etc.
--
SueLocke - 19 Jul 2005

Sue, thanks. That seems to have done it. I've given your suggestion a small tweak, so that the same search can be used (included, even) in each of the TradingStrategy pages. Here's my mod :
| *Topic:* | *Outcome* | *Expectations Met ?* |
%SEARCH{"[T]radingStrategy.*value\=.*%TOPIC%" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield(OUTCOMEOFTRADE) | $formfield(EXPECTATIONSMET) |" }%

Where does one go to learn about the gruelling little idiosyncracies of getting the syntax right when authoring a
FormattedSearch ? I think the author said it correctly in
SearchPatternCookbook 
what we need is a LONG list of examples. Specifically.. what is the idea behind the brackets surrounding the first letter of a search term, like this :
[T]
Those brackets around the first letter are found in multiple examples on twiki.org, such as:
The troublesome "first letter brackets" are even found in the broken search from
TopicClassificationAddOn. But, alas I've gone to try it without them and that
TWikiApplication is still broken :-/.
Regarding those problems in
TopicClassificationAddOn, I would still like to get those fixed up because the concept there is nice. Unsure yet whether that question will be addressed here, or in
TopicClassificationAddOnDev.
--
KeithHelfrich - 19 Jul 2005
Hey Keith - I moved your question from
TopicClassificationAddOn over to this topic since that one is more for development discussions. Hope that was OK. Your struggles certainly remind me of my initial forrays into formatted searches so I
know your frustration! You work with them for a while and, surprisingly, they start to make sense.
First, to answer your question about
what do the double brackets do? They keep the search from finding itself (i.e. including the topic that contains the %SEARCH within the search results). So you want to bracket the first letter of
both the Formfield you're searching (i.e. [T]radingStrategy)
and the value you looking for (i.e. [C]overedCall), assuming you don't use a variable (such as %TOPIC%).
Sounds like Sue answered your question about
HowToSearchForTopicNameInFormField. Great! The secrets of searches such as this one all lie in
RegularExpressions. If you google it, you'll find lots of introductory web pages. I found them maddeningly obscure at first but after a while even they start to make sense. (It's a little scary!

)
Now let's look at your problem with the search in
TopicClassificationAddOn. The search that creates the drop-down list in TopicTypeMaster
doesn't reference the table in the TopicType topic. It searches for topics with the
TopicType formfield set to TopicType. (As complex as this search seems, it's not nearly as difficult to design as extracting the values from the form. Plus, it produces more useful results.) So I would start by looking at the new TopicType topics you created and confirm that the TopicType formfield is set to TopicType. I seem to remember you changed the name of some of the web forms, so make sure your new TopicType topics
have forms that include the TopicType formfield. If that's the problem, make sure that the
template topic for new TopicType topics includes the proper form.
Oh, and one last thought. I think I
may be seeing some bugs in search in DEVELOP - so don't rule that out either...
Hope this helps!
--
LynnwoodBrown - 19 Jul 2005
Many thanks to both
SueLocke and
LynnwoodBrown for responding to my questions, and for doing so quickly! It is rewarding to find helpful answers to complicated questions given so generously by the
TWikiCommunity. Afterall, if this giant hairball is going to be complicated, then it is comforting to see we're not alone. I will now have to pay my dues to the Support web and contribute some answers of my own. The success of this interaction is appealing.
The good news :: my first homegrown
TWikiApplication is working correctly now and I've got a start on the know how to tweak it further. Regarding my problems with
TopicClassificationAddOn, it could certainly be the case that I did not yet understand the inner workings and rushed too quickly to customize. I'll have to give it another look in a couple of weeks, as new travel and new duties call.
Thanks again, take care.
--
KeithHelfrich - 20 Jul 2005
Hi Keith. My responsiveness is also guided by the generous support I have received from the TWiki community in helping me sort out glitches and stuff ups in my installations. I see it as a bit like barn raising and offering tools and expertise where you have them. You don't find that in many places nowadays. It was like a breath of fresh air when I first encountered it on TWiki. Hope to cross paths with you on the Support web from time to time
--
SueLocke - 21 Jul 2005