Jump to content






Photo

Just Google It



For the last phase of World Crisis we were to implement search on the site. To get started I looked for the SQL api for the Google DataStore. I needed to know the where syntax so I could throw the search terms at it. Of course, I didn't get very far, as the DataStore isn't a relational database with such conventions. Not to mention no join ability. So instead, we ran a basic full query and used Python to filter the rows. This method works, however to me it seems wasteful. As we go through the loops we loom through the search tokens, so it isn't the fastest search, but it works.

Once the basic search was taken care of, we had to implement the sorting and filtering mechanisms. This seemed easy enough but boy what a headache! I've done these before in PHP/HTML and the principles are the same, however including the "Hold Type X at Top of Results" was a real pain. Now, instead of basic sorting keys, we had to keep track of the current "Top" type. So in addition to the sorters name, type, kind, and location, we now had kind_c, kind_p, and kind_o for crises, people, and organizations. If one of those 3 were sent then the rows of the corresponding type would be placed at the top of the list. But the real pain was introduced when we had to keep the top rows stationary while sorting the remaining rows beneath by an alternative sorter. So it a dual-sorter of, well, sorts. So now in addition to the 7 sort keys, 9 more had to be introduced, of the form type_x_x. The first x represents what kind of rows to keep first, and the second x represents the "secondary" sort.

Next time we should just embed a google search form...

BTW, not sure why the tone of these blogs is always tired/annoyed, I rather enjoyed the coding experience. It just feels more natural to complain about something when blogging I guess.




or Sign In

My Picture

Recent Entries

May 2012

S M T W T F S
  12345
6789101112
13141516171819
20 212223242526
2728293031  

Recent Comments