Stop Ubuntu from sending your Desktop Searches

How to stop Ubuntu from sending your desktop searches to online retailers. Canonical has gotten a lot of flak for sharing Ubuntu users’ desktop searches to retailers. They plan to drop it with Unity 8 which is not scheduled until spring of 2016. Meanwhile, here’s a good article detailing how to disable your online search results.

Adding FULLTEXT Search

A few days ago, I wrote an article on how to add a search feature in CodeIgniter projects. The method I used was “Pattern Matching” using SQL’s LIKE statement. Although the LIKE statement works great, it is slow. The search will crawl in situations where there are millions of rows in a table.

An alternative method is using a FULLTEXT index search. It uses SQL’s MATCH AGAINST. To start using a FULLTEXT search, a database table will need to be indexed first. You can accomplish this by altering a table and adding FULLTEXT indexing to certain fields:

Alter Table

ALTER TABLE books ADD FULLTEXT(bookname,author,characters,synopsis);

Once a table has been indexed, you can start using MATCH AGAINST.

Match Against

I tried using CodeIgniter’s active record and MATCH AGAINST, but I could not get them to work. So, I ended up writing out the SQL statement using $this->db->query.

$match = $this->input->post('search');
$searchcount = $this->db->query("SELECT * FROM books WHERE MATCH 
  (bookname,author,characters,synopsis) AGAINST ('.$match.')");

So, if you want to increase search performance, consider using a FULLTEXT search.

Adding Search to CodeIgniter Projects

This is a little tutorial that will add a Search function to your CodeIgniter projects. As you may already know, CodeIgniter is a PHP Framework that uses the MVC model. MVC stands for Model, Views and Controller. This article assumes you’ve work with CodeIgniter before and that you are looking for a search feature that you can add to your application. To add the search feature, we will get started with the Controller.

Controller

This is assuming you already loaded your libraries, helpers and database model. Lets add the Search function.

function search()
{
$data['query'] = $this->Books_model->get_search();
$this->load->view(‘books’, $data);
}

Model

In this database query, I am searching for any matches in any of the 4 fields: bookname, author, characters and synopsis. If there are matches, it will return the results.

function get_search() {
  $match = $this->input->post(‘search’);
  $this->db->like(‘bookname’,$match);
  $this->db->or_like(‘author’,$match);
  $this->db->or_like(‘characters’,$match);
  $this->db->or_like(‘synopsis’,$match);
  $query = $this->db->get(‘books’);
  return $query->result();
}

Views

Here’s the search form.

<?=form_open(‘books/search’);?>
<?php $search = array(‘name’=>’search’,'id’=>’search’,'value’=>,);?>
<?=form_input($search);?><input type=submit value=’Search’ /></p>
<?=form_close();?>

The result can be displayed using a HTML table.

<table>
<tr><th>ID</th><th>Book</th><th>Author</th><th>Published</th><th>Price</th></tr>
<?php foreach($query as $item):?>
<tr>
<td><?= $item->id ?></td>
<td><?= $item->bookname ?></td>
<td><?= $item->author ?></td>
<td><?= $item->datepublished ?></td>
<td><?= $item->price ?></td>
</tr>
<?php endforeach;?>
</table>

Let me know what you think.

A Quick Look at Google Instant

Google Instant can predict results and complete searches before you even finish typing. Google boasts Instant can shave off time spent on searches. Definitely true. Google seems to be accurate 90% of the time, but the remaining 10% seems to be completely out of the blue.

Google Instant search seem to be based on location and personal preferences. Typing the letter A in the Google Instant Search bar for example, brought up Amazon, Aol and Apple. Typing B brought up BART. I’m sure the results wouldn’t be the same for someone living outside of the San Francisco Bay Area.

As far as personal searches, I have been searching for a Linksys WRT54GL lately. Typing WR brought up wrestling, writing and wrt54g. Not bad. It’s proof that results are indeed based on past personal searches.

Would I use Google Instant? Yes, definitely.

But, there might be instances where I may have to turn off Google Instant or use another search engine if it continues to give me random results. After all, a long brewed search at times is better than instant.