Item10080: /bin/search
issues different grep cmd than %SEARCH
Priority: Normal
Current State: No Action Required
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: SEARCH
Branches:
I use foswiki in the 1.0.9-1 Version (100% debian repository installation, OS debian lenny).
I have the {Site}{CharSet} = 'utf-8' (and that is fixed: I can not/will not change it).
I have a problem with the searches .....
I have thought out of the box there are 2 different searches: "simple search" (
WebSearch.txt) and "advanced search" (
WebSearchAdvanced.txt). Out of the box: (1) at the top bar there is the "simple search" bar (2) in
Main there is another search bar under "WebHome -> Web Utilities", on the right side of this one there is the link to the
WebSearchAdvanced topic.
I have thought the (1) is the simple search, the (2) is the advanced search with the default "advanced search option" checked, i.e. I was expecting searching something from this (2) bar would be exactly the same as searching in the
WebSearchAdvanced topic if I do not change any settings there.
I have just found out that it is not true.
2 Examples:
(example1) I have 1 topic where in the text of the topic there is the word "Performance". I search for "Performance" in (1) ==> no match (???), I search in
WebSearchAdvanced default ==> no match (???), I search in (2) ==> 1 match!
(example2) I have some topics where in the text of the topic there are the word "Beispiel" and "Zusammenspiel". I search for "spiel" in (1) ==> no match (???), I search in
WebSearchAdvanced default ==> no match (???), I search in (2) ==> a lot of matches!
This behavior looks to me random on "full words" and consegunet for regex (sub-strings). Sometimes it applyes even to capita/non capital (if I have "Hardware" in a topic and I search for "hardware" in the simple search and the Advanced topic sometimes I do not have any match sometimes I do have).
3 Questions:
why "Performance" is not found? is a "word" i.e. even the simple search should find it!!!.
which is the difference between (2) and the ystem.WebSearchAdvanced default ????
How to set for the top bar search (1) the same search type as (2)?
--
CatiaLavalle - 26 Nov 2010
trace active. Topic contains abgeschlossen. Search for geschlossen.
Top Bar Search => no match and in apache-error.log
[Fri Nov 26 09:40:32 2010] [error] [client 10.1.24.242] /bin/grep '-E' '-i' '-l' '-H' '--' '\\bgeschlossen\\b' '....' '....' -> , referer:
http://foswiki.home.de/foswiki/bin/view/Sandbox/WebSearch?search=geschlossen&scope=all&web=Sandbox
Advanced Search (default) => no match and in apache-error.log
[Fri Nov 26 09:44:02 2010] [error] [client 10.1.24.242] /bin/grep '-E' '-i' '-l' '-H' '--' '\\bgeschlossen\\b' '....' '....' -> , referer:
http://foswiki.home.de/foswiki/bin/view/Sandbox/WebSearchAdvanced?search=geschlossen&scope=all&order=topic&type=word&limit=all
[Fri Nov 26 09:44:03 2010] [error] [client 10.1.24.242] /bin/grep '-E' '-l' '-H' '--' '^%META:TOPICMOVED{.*\\bfrom=\\"Sandbox\\.XXXX\\"' '....' '....' -> , referer:
http://foswiki.home.de/foswiki/bin/view/Sandbox/WebSearchAdvanced?search=geschlossen&scope=all&order=topic&type=word&limit=all
WebHome -> Web Utlilities search => matches found and in apache-error.log
[Fri Nov 26 09:57:59 2010] [error] [client 10.1.24.242] /bin/grep '-F' '-i' '-l' '-H' '--' 'geschlossen' '....' '....' -> /var/lib/foswiki/data/Sandbox/TestTopic1.txt, referer:
http://foswiki.home.de/foswiki/bin/view/Sandbox/WebHome
--
CatiaLavalle - 26 Nov 2010
why:
(1) Top Bar Search searches for: /bin/grep '-E' '-i' '-l' '-H' '--' '\\bgeschlossen\\b'
(2) Advanced Search (default) searches for: /bin/grep '-E' '-i' '-l' '-H' '--' '\\bgeschlossen\\b'
(3)
WebHome -> Web Utlilities search searches for: /bin/grep '-F' '-i' '-l' '-H' '--' 'geschlossen'
Where is the Top Bar Search sefined?
How to change it i order to have the same result of "WebHome -> Web Utlilities search" ?????
--
CatiaLavalle - 29 Nov 2010
I have the solution:
cp
WebTopBarExample WebTopBar. Source Text edit
WebTopBar change in the quickSearchForm "form" from into /bin/search !!!!!
is this a bug? Anyway this solves my problem
--
CatiaLavalle - 29 Nov 2010
Note that as soon as I change view into "search" the grep changes from /bin//bin/grep '-E' '-i' '-l' '-H' '--' '\\bgeschlossen\\b' into /bin/grep '-F' '-i' '-l' '-H' '--' 'schlossen'
--
CatiaLavalle - 29 Nov 2010
I re-titled and set to new.
--
PaulHarvey - 06 Jul 2011
The difference between the grep commands is the difference between
fgrep
(fast grep) and
egrep
(extended grep).
egrep
is used in contexts where regular expressions are allowed in the search - for example, the
\b
, which is use to match a word break. Any
%SEARCH
macro that is
type="regex"
will get the
egrep
form, while default searches will not.
There are a number of things that can result in different results from the two searches:
- 'geschlossen' occurs in a topic, but does not occur as a word. For example,
nichtgeschlossen
will match fgrep 'geschlossen'
but will not match egrep '\\bgeschlossen\\b'
- grep version. The commands are written to use GNU 'grep'. If that's not what you have, then install GNU grep.
In summary, Foswiki is issuing the correct searches. My advice is to switch from using 'Forking' searches to using 'Native', which is more evenly supported across platforms.
--
CrawfordCurrie - 04 Apr 2014