Revision history for Mod029fImprovedSearch


Revision [23499]

Last edited on 2016-05-20 07:38:48 by PolVazo [Replaces old-style internal links with new pipe-split links.]
Additions:
**[[PolVazo | pmyatt]]** -- for the original idea and function code.
Deletions:
**[[PolVazo pmyatt]]** -- for the original idea and function code.


Revision [21641]

Edited on 2011-12-12 05:21:46 by PolVazo [Updated code for v1.3.1.]
Additions:
To to this in v1.3.1
In /libs/Wakka.class.php
Replace:
%%(php)
$sql = 'select * from '.$this->config['table_prefix'].'pages';
$sql .= ' where latest = '. "'Y'" .' and match(tag, body'.$id.')';
$sql .= ' against('. "'$search_phrase'" .' IN BOOLEAN MODE)';
$sql .= ' order by time DESC';
with
%%(php)
$sql = 'select * from '.$this->config['table_prefix'].'pages';
$sql .= ' where latest = '. "'Y'" . " and tag like('%" . mysql_escape_string($search_phrase) . "%') UNION select * from ";
$sql .= $this->config['table_prefix'] . 'pages where latest = '. "'Y'" .' and match(tag, body'.$id.')';
$sql .= ' against('. "'$search_phrase'" .' IN BOOLEAN MODE)';
$sql .= ' order by time DESC';


Revision [19284]

Edited on 2008-01-28 00:14:45 by JavaWoman [Modified links pointing to docs server]

No Differences

Revision [17204]

Edited on 2007-07-07 14:13:47 by JavaWoman [credit link]
Additions:
==== Wikka Mod 029 ====
Type: Feature Addition
----
===Credit:===
**[[PolVazo pmyatt]]** -- for the original idea and function code.
----

Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.

This will search for **partial** matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.


Here is the function I added in **wakka.php**:
%%(code)
function FullTextSearchAndLikeTags($phrase) {
return $this->LoadAll(" (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)
."%')) UNION (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))");
}
%%

Then I modified **actions/textsearch.php** and **actions/textsearchexpanded.php** to use the new function.
----
**Alternative way to do it**
This is the way I did it with MySQL v4 as the above only works with MySQL v3. In wikka.php change the function FullTextSearch from:
%%
{
$data = $this->LoadAll("select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
To:
%%
{
$data = $this->LoadAll(" select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%') UNION select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
--pmyatt

Deletions:
==== Wikka Mod 029 ====
Type: Feature Addition
----
===Credit:===
** pmyatt ** -- for the original idea and function code.
----

Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.

This will search for **partial** matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.


Here is the function I added in **wakka.php**:
%%(code)
function FullTextSearchAndLikeTags($phrase) {
return $this->LoadAll(" (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)
."%')) UNION (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))");
}
%%

Then I modified **actions/textsearch.php** and **actions/textsearchexpanded.php** to use the new function.
----
**Alternative way to do it**
This is the way I did it with MySQL v4 as the above only works with MySQL v3. In wikka.php change the function FullTextSearch from:
%%
{
$data = $this->LoadAll("select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
To:
%%
{
$data = $this->LoadAll(" select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%') UNION select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
--pmyatt




Revision [16954]

Edited on 2007-05-31 23:27:31 by JsnX [Reverted]
Additions:
==== Wikka Mod 029 ====
Type: Feature Addition
----
===Credit:===
** pmyatt ** -- for the original idea and function code.
----

Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.

This will search for **partial** matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.


Here is the function I added in **wakka.php**:
%%(code)
function FullTextSearchAndLikeTags($phrase) {
return $this->LoadAll(" (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)
."%')) UNION (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))");
}
%%

Then I modified **actions/textsearch.php** and **actions/textsearchexpanded.php** to use the new function.
----
**Alternative way to do it**
This is the way I did it with MySQL v4 as the above only works with MySQL v3. In wikka.php change the function FullTextSearch from:
%%
{
$data = $this->LoadAll("select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
To:
%%
{
$data = $this->LoadAll(" select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%') UNION select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
--pmyatt


Deletions:
==== Wikka Mod 029 ====
Type: Feature Addition
----
===Credit:===
** pmyatt ** -- for the original idea and function code.
----

Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.

This will search for **partial** matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.


Here is the function I added in **wakka.php**:
%%(code)
function FullTextSearchAndLikeTags($phrase) {
return $this->LoadAll(" (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)
."%')) UNION (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))");
}
%%

Then I modified **actions/textsearch.php** and **actions/textsearchexpanded.php** to use the new function.
----
**Alternative way to do it**
This is the way I did it with MySQL v4 as the above only works with MySQL v3. In wikka.php change the function FullTextSearch from:
%%
{
$data = $this->LoadAll("select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
To:
%%
{
$data = $this->LoadAll(" select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%') UNION select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
--pmyatt



Revision [16753]

Edited on 2007-05-31 10:44:31 by HphBt0 [Reverted]
Additions:
==== Wikka Mod 029 ====
Type: Feature Addition
----
===Credit:===
** pmyatt ** -- for the original idea and function code.
----

Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.

This will search for **partial** matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.


Here is the function I added in **wakka.php**:
%%(code)
function FullTextSearchAndLikeTags($phrase) {
return $this->LoadAll(" (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)
."%')) UNION (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))");
}
%%

Then I modified **actions/textsearch.php** and **actions/textsearchexpanded.php** to use the new function.
----
**Alternative way to do it**
This is the way I did it with MySQL v4 as the above only works with MySQL v3. In wikka.php change the function FullTextSearch from:
%%
{
$data = $this->LoadAll("select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
To:
%%
{
$data = $this->LoadAll(" select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%') UNION select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
--pmyatt

Deletions:
==== Wikka Mod 029 ====
Type: Feature Addition
----
===Credit:===
** pmyatt ** -- for the original idea and function code.
----

Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.

This will search for **partial** matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.


Here is the function I added in **wakka.php**:
%%(code)
function FullTextSearchAndLikeTags($phrase) {
return $this->LoadAll(" (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)
."%')) UNION (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))");
}
%%

Then I modified **actions/textsearch.php** and **actions/textsearchexpanded.php** to use the new function.
----
**Alternative way to do it**
This is the way I did it with MySQL v4 as the above only works with MySQL v3. In wikka.php change the function FullTextSearch from:
%%
{
$data = $this->LoadAll("select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
To:
%%
{
$data = $this->LoadAll(" select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%') UNION select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
--pmyatt




Revision [2586]

Edited on 2004-11-28 20:32:49 by JsnX [thanks]
Additions:
--pmyatt
''Great, thanks. This will be added to version 1.1.5.4.'' -- JsnX
Deletions:
--pmyatt


Revision [2584]

Edited on 2004-11-28 19:29:02 by PolVazo [thanks]
Additions:
--pmyatt
Deletions:
}


Revision [2583]

Edited on 2004-11-28 19:27:58 by PolVazo [thanks]
Additions:
==== Wikka Mod 029 ====
Type: Feature Addition
----
===Credit:===
** pmyatt ** -- for the original idea and function code.
----

Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.

This will search for **partial** matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.


Here is the function I added in **wakka.php**:
%%(code)
function FullTextSearchAndLikeTags($phrase) {
return $this->LoadAll(" (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)
."%')) UNION (select * from ".$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))");
}
%%

Then I modified **actions/textsearch.php** and **actions/textsearchexpanded.php** to use the new function.
----
**Alternative way to do it**
This is the way I did it with MySQL v4 as the above only works with MySQL v3. In wikka.php change the function FullTextSearch from:
%%
{
$data = $this->LoadAll("select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
%%
To:
%%
{
$data = $this->LoadAll(" select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%') UNION select * from "
.$this->config["table_prefix"]
."pages where latest = 'Y' and match(tag, body) against('".mysql_real_escape_string($phrase)
."' IN BOOLEAN MODE) order by time DESC");
}
Deletions:
==== Wikka Mod 029 ====
Type: Feature Addition
----
===Credit:===
** pmyatt ** -- for the original idea and function code.
----

Use MySQL "UNION" to search for text in TAG as well as the full text search that often returns no results.

This will search for **partial** matches in page titles (tags). This is of great benefit because the regular search would not find a search for the word "camel" even if you had a page named "CamelCase". This modified search will now find that page.


Here is the function I added in **wakka.php**:
%%(code)
function FullTextSearchAndLikeTags($phrase) { return $this->LoadAll(" (select * from ".$this->config["table_prefix"]."pages where latest = 'Y' and tag like('%".mysql_escape_string($phrase)."%')) UNION (select * from ".$this->config["table_prefix"]."pages where latest = 'Y' and match(tag, body) against('".mysql_escape_string($phrase)."'))"); }
%%

Then I modified **actions/textsearch.php** and **actions/textsearchexpanded.php** to use the new function.


Revision [141]

The oldest known version of this page was created on 2004-04-09 01:12:27 by JsnX [thanks]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki