Loading...
 
Skip to main content

Features / Usability


Boolean Searching modification

posts: 130

Hello,

We have an internal staff intranet at our library that is built upon tikiwiki, and thanks to the community, it has grown by leaps and bounds and now has over a 1000 wiki pages, hundreds of blog posts, forum discussions, etc.

One of the things that became quickly apparent to us is that the built in search features of tikiwiki were not robust enough for us....I dont think this is a big problem for most, as they can just integrate some type of google search module into their site. But if your site is behind a firewall, and therefore cannot be indexed by google, that option is not available.

We had a university student by the name of Will Hutchison who took a look at this problem for us and gave us a quick solution. It is working for us, and now we have phrase searching (with qoutes) as well as + and - operators. The replacement file is attached to this forum post.....

Be careful with this code, I mainly post it here to try and give a little back to the community. My concern here is that the code change might open yourself to sql injection, not a concern for us. My understanding is that there were only two line changes to the sql statements which changed the way it encoded the html search phrase. I am hoping someone with more time can improve this code and include it in future releases.

For example, if you did a normal search for narrative nonfiction on our tikiwiki before the code enhancement, you would receive 34 hits.

After the code enhancement, if you do a phrase search "narrative nonfiction" (make sure you use the qoutes), you come up with 3 results.

If you do "narrative nonfiction" -subjects (which states show me all content that has the phrase narrative nonfiction but does NOT have the word subject), you will see two results, the page with the word subject dropping off.

posts: 1817 Catalan Countries

Hi seromine

and THANKS!!!!!!! That's a kind of dream which became true!!!! THANKS, THANKS, THANKS! 😀

I'm forwarding your message to the tikiwiki-devel list at sf.net, so that developers can give more attention to your hack, and hopefully, change it if needed in order to allow incorporating your hack into the main code base (I hope it can be integrated for everyone, with whatever patches needed to your code, if so)

Yours sincerely

Xavi


posts: 1092

Strange in the attached file, I can not find the code...
Can you attach a diff and which release you are using
Thanks
If you want also th join the devel team - welcome


posts: 130

Terribly sorry! Looks like I posted the wrong searchlib.php from another server!

Attached is the correct one, and sorry to waste your time. Below is the relevant section of the code. Notice the html_entity_decode....this was the crux of the solution, but might open itself up to sql injection type stuff...not an issue for me, as we are behind a firewall...but knowing this improved the issue for us, there might be some additional workaround someone might be able to figure out....

Image
Copy to clipboard
if ($fulltext) { $words = html_entity_decode($words); $qwords = $this->db->quote($words); $sqlft = 'MATCH(' . join(',', $h['search']). ') AGAINST (' . $qwords . ' IN BOOLEAN MODE)'; $sqlWhere .= ' AND ' . $sqlft ; $sqlFields .= ', ' . $sqlft . ' AS relevance'; $orderby = 'relevance desc, ' . $orderby;