You are viewing this page out of context. To see it in the context it is intended please click here.
About This Page
Reply posted by Laurens Lochtenberg on Tue 12 Feb 2002 in response to URL Syntax for advanced field level searching
Google style search queries
Dear all,Being fond of the intuitive Google, I've made a $$return field, that translates
a Google style search query into Notes style. This means you don't have to put
operators like "AND" or "NOT" in the query. "AND" is automatically added, a
hyphen can be used for "NOT". "OR" is the same in Notes as in Google. If anyone
can do this in Javascript, I'd be more than happy.
Here is the code:
REM "this code works for maximum of 2 pairs of quotation marks, though you can
extend using more subsets";
REM "hyphen can be part of a word, or can be used as NOT placed at the
beginning of a search string, before a quotation mark and before a searchterm";
t0000:=@LowerCase(@Trim(Your_Query_Field));
t000:=@If(@Begins(t0000;"-")=1;" "+t0000;t0000);
REM "the hyphens that are not part of a word-combination are replaced by NOT
and before and after quotation marks # (pound-keys) are placed";
t00:=@ReplaceSubstring(t000;
"- " :" -" : "not\""
: " \"" :"\" " ;
"not " :" not " : "not \"" :
"#\"" :"\"#"
);
t0:=@Explode(t00;"#");
REM "the query is split into elements, where everything between quotation marks
is a seperate element";
t1:=@Subset(t0;1);
t2:=@Subset(@Subset(t0;2);-1);
t3:=@Subset(@Subset(t0;3);-1);
t4:=@Subset(@Subset(t0;4);-1);
t5:=@Subset(@Subset(t0;5);-1);
REM "Replace the space characters in an element that starts with a quotation
mark by %20";
tt1:=@If(@Begins(t1;"\"")=1;@ReplaceSubstring(t1;" ";"%20");t1);
tt2:=@If(@Begins(t2;"\"")=1;@ReplaceSubstring(t2;" ";"%20");t2);
tt3:=@If(@Begins(t3;"\"")=1;@ReplaceSubstring(t3;" ";"%20");t3);
tt4:=@If(@Begins(t4;"\"")=1;@ReplaceSubstring(t4;" ";"%20");t4);
tt5:=@If(@Begins(t5;"\"")=1;@ReplaceSubstring(t5;" ";"%20");t5);
REM "the elements are combined again with spaces in between them";
xt1:=@Trim(@Implode(@Unique(tt1:tt2:tt3:tt4:tt5:tt5);" "));
REM "replaces spaces with AND and make corrections made for NOT and OR in
combination with spaces";
xt2:=@ReplaceSubstring(xt1;
" & " :" or " : "not " : " contains ": " " ;
"%20%26%20" :"%20or%20": "not%20": "%20contains%20" : "%20and%20");
"[/" + Your_Database + "/Your_Search_View?SearchView&Query=" + xt2 + "]"
The search tips for users to use with this way of queriying. It is quite the
same as the google syntax:
search tips:
- "AND" is automatically placed between your search terms
- use a hyphen "-" to exclude words from your search
- use asterix "*" as wildcard, e.g. 'codesto*'
- use quotation marks for a combination of words e.g. "jake howlett"