Tuesday, April 10, 2007

fastget documentation

Today I have investigate stupid fastget tool. After 4 hours of installing|removing|reinstalling different packages on Debian it was running and I can to investigate all internal functions. @ hours more. I have had a nice manual how it work ... And ... This moment I found one function fg-help and understanding that I stupid either. But the result of this function is not fully. Therefore I post my manual for other use.

All fastget functions investigated by me:

fg_add_category

fg_add_category database category_name

fg_add_category_to_category
fg_add_category_to_category database category_id parent_category_id

fg_category_index
fg_category_index database document_id "category_id category_id*"

fg_command_line
command line

fg_create_db
fg_create_db database

fg_delete_category
fg_delete_category database category_id

fg_flatfile_categories_to_sql
fg_flatfile_categories_to_sql flatfile sql_db_name hostname user password [link_to_top]
This is a handy utility to turn a text file into a heirarchy. Heres an example format:
Number of widgets
1 to 3
1
2
3
4 to 6
4
5
6
7 and up
7
8
9
10
No set amount
Also remember to create the tables in the db
CREATE TABLE fg_category ( id, name );
CREATE TABLE fg_category_to_category ( category_id, category_parent_id );

fg_get_category
fg_get_category database category_id

fg_get_children_categories
fg_get_children_categories database category_id

fg_get_full_tree
fg_get_full_tree database count_accuracy extra_search category_id_str remove_empty_categories

fg_get_items_in_category
fg_get_items_in_category database category_id_string ascending first number keywords

fg_get_tree
fg_get_tree database count_accuracy extra_search category_id_str remove_empty_categories

fg_index
fg_index database document_id "keywords"

fg_search
fg_search database ascending first number keywords

fg_set_category
fg_set_category database category_id category_name

fg_sql_db_to_fastget_db
Sample pseudo code for loading a fastget db with a sql db heirarchy

I considered providing code but it's so system specific and yet simple
that I think it's better to just have a simple blueprint or two of how
one might do it.

Here is a bulk loading method.

Generally speaking this is the fastest way to deal with indices.
However this way, alone, introduces latency if the data changes.
Latency can be dealt with by validating the results versus the DB
or by updating the index realtime. It can be minimized by building
the index frequently.

1) load the categories.

SELECT * FROM category ORDER BY id

foreach {
fg_set_category( , )
}

2) load the structure of the categories.

SELECT * FROM category_to_category
fg_add_category_to_category( category_id, category_parent_id );
}

3) associate documents or items or data with the categories.

SELECT GROUP_BY_CONCAT(category_id) as category_ids, document_id
FROM document_to_category
GROUP BY document_id

fg_category_index(document_id, category_ids)


4) associate keywords with items

SELECT keywords FROM item

fg_index(document_id, keywords)


fg_help;

fg_add_category database category_name;
fg_add_category_to_category database category_id parent_category_id;
fg_category_index database document_id "category_id category_id*";
fg_delete_category database category_id;
fg_set_category database category_id parent_category_id;
fg_get_children_categories database category_id;
fg_get_full_tree database count_accuracy extra_search category_id_str remove_empty_categories;
fg_get_items_in_category database category_id_string ascending first number keywords;
fg_search database ascending first number keywords;
fg_parent_category_id database category_id;
fg_index database document_id "keywords";
fg_set_category database category_id category_name;
fg_save;