Question
Hello guys and girls!
I have probably really stupid question but can't find the answer.
Where are the search results stored?
Let me explain.
If I have a table
and this search
%SEARCH{ "\|[^\|]*\|[^\|]*\|[^\|]*\|" topic="%TOPIC%" regex="on" multiple="on" nosearch="on" nototal="on"
format="$pattern(^(\|[^\|]*\|).*)$pattern(^\|[^\|]*\|[^\|]*\|([^\|]*\|).*)" }%
The result is
| Year |
1999 |
| Low |
10 |
| Target |
12 |
| High |
15 |
| Actual |
14 |
but when I look in *.txt or Raw View I can't find there any search results.
So I don't see this form
| *Year* | *1999* |
| *Low* | 10 |
| *Target* | 12 |
| *High* | 15 |
| *Actual* | 14 |
Is it possible to format search results in a table form and how?
Hope someone can explain me and help me with this matter.
Damijan
Environment
--
TWikiGuest - 21 Jul 2006
Answer
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.
Hm, I'm not sure, but doesn't
AttachContentPlugin provide this functionality?
--
FranzJosefSilli - 21 Jul 2006
Hmm, Josef
I am afraid not. If I put
%STARTATTACH{"trialhope.txt"}%
at the beginning of the page and
%ENDATTACH%
at the end of page, I get just structure of the page when I click preview or edit button.
When I am in View mode and I am using the search option the results are not displayed.
And trialhope.txt is intact.
If I put
%STARTATTACH{"trialhope.txt"}%
%ENDATTACH%
just around search function results are just displayed and trialhope.txt is again intacted.
Hmm this is obviously not solution I am afraid.
Is there any option within the
%SEARCH{ "\|[^\|]*\|[^\|]*\|[^\|]*\|" topic="%TOPIC%" regex="on" multiple="on" nosearch="on" nototal="on" format="$pattern(^(\|[^\|]*\|).*)$pattern(^\|[^\|]*\|[^\|]*\|([^\|]*\|).*)" }%
To export to a real table (or file or whatever can be grep-ed, or awk-ed?).
And thank you for spending your time for me

A deep bow
Damijan
--
TWikiGuest - 21 Jul 2006
Sorry it didn't work, but I'm sure
MeredithLesly implemented something along this path, can't find it right now.

Keep looking!
I once misused
EditTablePlugin to 'capture' tabular search results. See sample below.
--
FranzJosefSilli - 21 Jul 2006
The SEARCH is not stored anywhere, that is, you will see a dynamically generated table every time you look at the page. You can use the dynamically generated table further, such as to generate a chart using the
ChartPlugin.
Do you have a need to save the search result?
--
PeterThoeny - 21 Jul 2006
I am afraid I need to have.
I am writing a Perl script for replacing text from table form
so
| *Year* | *1999* |
| *Low* | 10 |
| *Target* | 12 |
| *High* | 15 |
| *Actual* | 14 |
to a form appropriate for
DirectedGraph plugin.
I have found Search and replace plugin to do this job but it demands user interaction, which is in my case not an option.
And I think you can change just one search string at the time and not around 6 as in my case.
So I want (need) to have search results somehow stored in a file (but not in database) because otherwise users can't press the e.g. Replace button which would trigger the perl program.
The final users are going to be also unexperienced users, so I can't imagine them to go in edit mode or so.
I don't know what to do.
At the moment I have 3 working parts (OK almost

) which I need to combine together. Crucial for me is to have a search results in a file, otherwise Perl program can't be used.
I haven't got the slightest idea how to replace results into appropriate form for
DirectedGraph in any other way as to do this with a Perl program triggered with e.g. Replace button.
Any ideas?
Cheers,
D.
--
TWikiGuest - 21 Jul 2006
You can call
TWiki::Func::expandCommonVariables( "%SEARCH{ ... }%", $topic, $web ) in your Plugin to expand a SEARCH in memory, and then save the result into a file (for example in the Plugin workarea.)
--
PeterThoeny - 21 Jul 2006
I will check Peter, but I think I am far away being capable to do this

.
I have no idea how to successfully finish this so I will probably convert the whole Topic (which contains table to another file directly through pointing to this Perl script and hopefully will
DirectedPlugin inside TWiki create a graph.
There are many drawbacks doing this:
- Main is the graphics creation time,
- because there can be a lot of entries over time, would be almost impossible to find any connections between different groups,
- another is User will probably need to refresh Page to see the graphics.
I know this solution is quite impractical and maybe even strange for you Guru's, but I am not a programmer, but GIS postgrad.
Anyway, thank you P. and also F. for help.
D.
--
TWikiGuest - 22 Jul 2006
Hmm, the
AttachContentPlugin should provide a "save file based on partial topic text" feature. That is, you shoule be able to put a SEARCH inside STARTATTACH and ENDATTACH. Post a not on the
AttachContentPluginDev topic if this does not work.
--
PeterThoeny - 22 Jul 2006
Hmm, strange now it works. Search works?!?
I don't know what went wrong in my previous trials.
Of course dynamically generated table is not cached.
--
TWikiGuest - 22 Jul 2006
I have tried with
TWiki::Func::expandCommonVariables( "%SEARCH{ ... }%", $topic, $web ) , and send to file but the result is strange. I am probably doing something wrong.
Here is my syntax
my $thisIsBloodyTry = TWiki::Func::expandCommonVariables("%SEARCH{ ... }%", 'SearchAndExtract', 'Main');
print OUTPUT ($thisIsBloodyTry);
As a result I don't capture any search results but this
<span class="patternSearched">Searched: <b><nop>...</b></span><span id="twikiNumberOfResultsContainer"></span><span id="twikiModifySearchContainer"></span>
<h4 class="patternSearchResultsHeader" style="background-color:#B9DAFF"><span class="twikiLeft"><b>Results from <nop>Sandbox web</b> retrieved at 11:02 (GMT)</span><span class="twikiRight"></span><br class="twikiClear" /></h4>
and so on.
What am I doing wrong? Hmm, maybe would be better to put this into another topic with the name smth like How to use expandCommonVariables.
Damijan
--
TWikiGuest - 05 Aug 2006
Did you replace the
... in
%SEARCH{ ... }% with the actual search term and parameters (
nonoise="on" etc)?
--
PeterThoeny - 05 Aug 2006
My whole SEARCH syntax is
%SEARCH{ search="META:FIELD.*?SurnameName.*?%URLPARAM{"qNam"}%;META:FIELD.*?OtherInfluentalPeople.*?%URLPARAM{"qOth"}%;META:FIELD.*?RelationshipTo.*?%URLPARAM{"qRel"}%;META:FIELD.*?ImportanceOfRelationship.*?%URLPARAM{"qImp"}%;META:FIELD.*?EntryAddedBy.*?%URLPARAM{"qAdd"}%" topic="IndividualsEdit2*" nosearch="on" nototal="on" regex="on" noheader="on" format="| [[$topic][<img src=\"%PUBURLPATH%/%TWIKIWEB%/TWikiDocGraphics/viewtopic.gif\" border=\"0\" alt=\"View entry\" />]] [[%SCRIPTURL%/edit%SCRIPTSUFFIX%/%WEB%/$topic?t=%GMTIME{"$hour$min$sec"}%][<img src=\"%PUBURLPATH%/%TWIKIWEB%/TWikiDocGraphics/edittopic.gif\" border=\"0\" alt=\"Edit entry\" />]] | $formfield(SurnameName) | $formfield(OtherInfluentalPeople) | $formfield(RelationshipTo) | $formfield(ImportanceOfRelationship) | $formfield(EntryAddedBy) | $formfield(ReferencesNotes) |" }%
but data I'm searching for are probably within this
| $formfield(SurnameName) | $formfield(OtherInfluentalPeople) | $formfield(RelationshipTo) | $formfield(ImportanceOfRelationship) | $formfield(EntryAddedBy) | $formfield(ReferencesNotes) |
However, if I put this part into
TWiki::Func::expandCommonVariables("| $formfield(SurnameName) | $formfield(OtherInfluentalPeople) | $formfield(RelationshipTo) | $formfield(ImportanceOfRelationship) | $formfield(EntryAddedBy) | $formfield(ReferencesNotes) |", 'SearchAndExtract', 'Main');
the result is not real data but this syntax?
If I want to use the whole
%SEARCH{ search= etc. | "}% there is an error probably because
"
or because use of
use strict; option
And this is an error message from %FAILEDPLUGINS%
syntax error at /srv/www/htdocs/twiki/lib/TWiki/Plugins/SearchTestPlugin.pm line 222, near ""%%SEARCH{ search="META"
syntax error at /srv/www/htdocs/twiki/lib/TWiki/Plugins/SearchTestPlugin.pm line 222, near "%;META
TA D.
--
TWikiGuest - 05 Aug 2006
You need to escape double quotes located in a string. E.g.
TWiki::Func::expandCommonVariables( "%SEARCH{ search=\"META:FIELD.*?SurnameName.*?;%URLPARAM{\"qNam\"}%;META:FIELD.*?...}%", .... You can also use single quotes:
TWiki::Func::expandCommonVariables( '%SEARCH{ search="META:FIELD.*?SurnameName.*?%URLPARAM{"qNam"}%;META:FIELD.*?...}%', ... (with this you do not need to escape the double quotes.)
--
PeterThoeny - 05 Aug 2006
I have found two hits from test search.
<div class="patternSearchResult"><div class="twikiTopRow"><div class="twikiLeft"><a href="/twiki/bin/view/Main/IndividualsEdit20060730171722"><b>IndividualsEdit20060730171722</b></a></div><div class="twikiRight twikiSRAuthor"> <a href="/twiki/bin/view/Main/DamijanBec" class="twikiLink">DamijanBec</a></div><div class="twikiRight twikiSRRev"><span class="twikiNew">NEW</span> - <a href="/twiki/bin/rdiff/Main/IndividualsEdit20060730171722" rel='nofollow'>30 Jul 2006 - 18:23</a> </div><br class="twikiClear" /></div><!--/twikiTopRow--><div class="twikiBottomRow"><div class="twikiSummary twikiGrayText">TWiki Installation Entry Back to <nop>IndividualsEdit <nop>DamijanBec 30 Jul 2006</div><!--/twikiSummary-->
</div><!--/twikiBottomRow--></div><!--/patternSearchResult--><div class="patternSearchResult"><div class="twikiTopRow"><div class="twikiLeft"><a href="/twiki/bin/view/Main/IndividualsEdit20060805234147"><b>IndividualsEdit20060805234147</b></a></div><div class="twikiRight twikiSRAuthor"> <a href="/twiki/bin/view/Main/DamijanBec" class="twikiLink">DamijanBec</a></div><div class="twikiRight twikiSRRev"><span class="twikiNew">NEW</span> - <a href="/twiki/bin/rdiff/Main/IndividualsEdit20060805234147" rel='nofollow'>05 Aug 2006 - 23:45</a> </div><br class="twikiClear" /></div><!--/twikiTopRow--><div class="twikiBottomRow"><div class="twikiSummary twikiGrayText">TWiki Installation Entry Back to <nop>IndividualsEdit <nop>DamijanBec 05 Aug 2006</div><!--/twikiSummary-->
</div><!--/twikiBottomRow--></div><!--/patternSearchResult-->
And in this file are results
<a href="/twiki/bin/rdiff/Main/IndividualsEdit20060730171722"
<a href="/twiki/bin/rdiff/Main/IndividualsEdit20060805234147"
Is there a way to get instead of links (even though quite usable) real data in this form
| $formfield(SurnameName?) | $formfield(OtherInfluentalPeople?) | $formfield(RelationshipTo?) | $formfield(ImportanceOfRelationship?) | $formfield(EntryAddedBy?) | $formfield(ReferencesNotes?) |
from all hits?
Or shall I do this in my plugin with opening files and merging together and then "extract" in desired form?
--
TWikiGuest - 05 Aug 2006
It still looks as if the format parameter is not used properly. Try first to get a proper search in a TWiki topic, then move it into the Perl code.
--
PeterThoeny - 06 Aug 2006

Yes it works!
The problem was that I forgot that I backslashed the last " before
so I had in my Perl code ending with |\" }%
Thank you Peter!
I already managed to draw a title of diagram. At the moment I don't have complete diagram 'cos the searching Perl syntax should be modified.
Thank you,
Damijan
--
TWikiGuest - 06 Aug 2006