Commit 06bf22bb authored by Jamie McCracken's avatar Jamie McCracken

Modified to fit in new metadata engine

parent bd99cb04
This diff is collapsed.
......@@ -27,11 +27,12 @@
typedef enum {
DATA_INDEX_STRING,
DATA_INDEX,
DATA_STRING,
DATA_NUMERIC,
DATA_DATE,
DATA_INDEX_BLOB
DATA_BLOB,
DATA_KEYWORD
} DataTypes;
......@@ -46,8 +47,8 @@ typedef enum {
typedef struct {
char *id;
DataTypes type;
gboolean writeable;
gboolean embedded;
gboolean multiple_values;
int weight;
} FieldDef;
......@@ -104,13 +105,28 @@ int tracker_db_flush_words_to_qdbm (DBConnection *db_con, int limit);
void tracker_db_release_memory ();
char * tracker_get_related_metadata_names (DBConnection *db_con, const char *name);
char * tracker_get_metadata_table (DataTypes type);
char *** tracker_db_search_text (DBConnection *db_con, const char *service, const char *search_string, int offset, int limit, gboolean save_results, gboolean detailed);
char *** tracker_db_search_files_by_text (DBConnection *db_con, const char *text, int offset, int limit, gboolean sort);
char *** tracker_db_search_metadata (DBConnection *db_con, const char *service, const char *field, const char *text, int offset, int limit);
char *** tracker_db_search_matching_metadata (DBConnection *db_con, const char *service, const char *id, const char *text);
/* gets metadata as a single row (with multiple values delimited by semicolons) */
char *** tracker_db_get_metadata (DBConnection *db_con, const char *service, const char *id, const char *key);
void tracker_db_set_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value, gboolean overwrite, gboolean index, gboolean embedded);
/* gets metadata using a separate row for each value it has */
char *** tracker_db_get_metadata_values (DBConnection *db_con, const char *service, const char *id, const char *key);
void tracker_db_set_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value, gboolean generate_display_metadata, gboolean index, gboolean embedded);
void tracker_db_delete_metadata_value (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value, gboolean embedded);
void tracker_db_delete_metadata (DBConnection *db_con, const char *service, const char *id, const char *key);
char * tracker_db_refresh_display_metadata (DBConnection *db_con, const char *id, const char *metadata_id, int data_type, const char *key);
void tracker_db_refresh_all_display_metadata (DBConnection *db_con, const char *id);
void tracker_db_update_keywords (DBConnection *db_con, const char *service, const char *id, const char *value);
void tracker_db_create_service (DBConnection *db_con, const char *path, const char *name, const char *service, const char *mime, guint32 filesize, gboolean is_dir, gboolean is_link, int offset, guint32 mtime);
......
......@@ -211,7 +211,7 @@ tracker_db_get_file_info (DBConnection *db_con, FileInfo *info)
static void
tracker_db_add_embedded_keywords (DBConnection *db_con, const char *file_id, const char *keywords)
tracker_db_add_embedded_keywords (DBConnection *db_con, const char *file_id, const char *keyword_type, const char *keywords, gboolean index)
{
char **array, **tags;
char *tag;
......@@ -223,9 +223,10 @@ tracker_db_add_embedded_keywords (DBConnection *db_con, const char *file_id, con
tag = *tags;
tag = g_strstrip (tag);
if (strlen (tag) > 2) {
if (strlen (tag) > 0) {
tracker_log ("Auto-tagging file with %s", tag);
tracker_exec_proc (db_con, "AddEmbeddedKeyword", 2, file_id, tag);
tracker_db_set_metadata (db_con, "Files", file_id, keyword_type, tag, FALSE, index, TRUE);
// tracker_exec_proc (db_con, "AddEmbeddedKeyword", 3, file_id, keyword_type, tag);
}
}
......@@ -289,13 +290,16 @@ get_meta_table_data (gpointer key,
g_free (evalue);
}
tracker_db_set_metadata (db_action->db_con, "Files", db_action->file_id, mtype, mvalue, TRUE, TRUE, TRUE);
/* auto-tag keyword related metadata */
if ( (strcasecmp (mtype, "Doc.Keywords") == 0) || (strcasecmp (mtype, "Image.Keywords") == 0) ) {
tracker_db_add_embedded_keywords (db_action->db_con, db_action->file_id, mvalue);
if ( (strcasecmp (mtype, "Doc:Keywords") == 0) || (strcasecmp (mtype, "Image:Keywords") == 0) ) {
tracker_db_add_embedded_keywords (db_action->db_con, db_action->file_id, mtype, mvalue, TRUE);
} else {
tracker_db_set_metadata (db_action->db_con, "Files", db_action->file_id, mtype, mvalue, FALSE, TRUE, TRUE);
}
if (mvalue) {
g_free (mvalue);
}
......@@ -356,11 +360,13 @@ get_meta_table_data_new (gpointer key,
g_free (evalue);
}
tracker_db_set_metadata (db_action->db_con, "Files", db_action->file_id, mtype, mvalue, TRUE, FALSE, TRUE);
/* auto-tag keyword related metadata */
if ( (strcasecmp (mtype, "Doc.Keywords") == 0) || (strcasecmp (mtype, "Image.Keywords") == 0) ) {
tracker_db_add_embedded_keywords (db_action->db_con, db_action->file_id, mvalue);
if ( (strcasecmp (mtype, "Doc:Keywords") == 0) || (strcasecmp (mtype, "Image:Keywords") == 0) ) {
tracker_db_add_embedded_keywords (db_action->db_con, db_action->file_id, mtype, mvalue, FALSE);
} else {
tracker_db_set_metadata (db_action->db_con, "Files", db_action->file_id, mtype, mvalue, FALSE, FALSE, TRUE);
}
if (mvalue) {
......@@ -523,7 +529,7 @@ tracker_db_save_thumbs (DBConnection *db_con, const char *small_thumb, const cha
char *small_thumb_file;
small_thumb_file = tracker_escape_string (db_con, small_thumb);
tracker_db_set_metadata (db_con, "Files", str_file_id, "File.SmallThumbnailPath", small_thumb_file, TRUE, FALSE, TRUE);
//tracker_db_set_metadata (db_con, "Files", str_file_id, "File.SmallThumbnailPath", small_thumb_file, TRUE, FALSE, TRUE);
// tracker_exec_proc (db_con, "SetMetadata", 5, "Files", str_file_id, "File.SmallThumbnailPath", small_thumb_file, "1");
g_free (small_thumb_file);
}
......@@ -532,8 +538,7 @@ tracker_db_save_thumbs (DBConnection *db_con, const char *small_thumb, const cha
char *large_thumb_file;
large_thumb_file = tracker_escape_string (db_con, large_thumb);
tracker_db_set_metadata (db_con, "Files", str_file_id, "File.LargeThumbnailPath", large_thumb_file, TRUE, FALSE, TRUE);
// tracker_exec_proc (db_con, "SetMetadata", 5, "Files", str_file_id, "File.LargeThumbnailPath", large_thumb_file, "1");
// tracker_db_set_metadata (db_con, "Files", str_file_id, "File.LargeThumbnailPath", large_thumb_file, TRUE, FALSE, TRUE);
g_free (large_thumb_file);
}
......@@ -601,6 +606,11 @@ tracker_metadata_is_date (DBConnection *db_con, const char *meta)
def = tracker_db_get_field_def (db_con, meta);
if (!def) {
tracker_log ("failed to get info for metadata type %s", meta);
return FALSE;
}
g_return_val_if_fail (def, FALSE);
res = (def->type == DATA_DATE);
......
......@@ -124,11 +124,11 @@ tracker_dbus_method_files_exists (DBusRec *rec)
str_file_id = tracker_uint_to_str (file_id);
if (file_id > 0) {
tracker_db_set_metadata (db_con, service, str_file_id, "File.Name", name, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File.Path", path, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File.Format", mime, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File.Modified", str_mtime, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File.Size", str_size, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Name", name, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Path", path, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Format", mime, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Modified", str_mtime, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Size", str_size, TRUE, TRUE, TRUE);
}
if (name) {
......@@ -227,11 +227,11 @@ tracker_dbus_method_files_create (DBusRec *rec)
str_file_id = tracker_uint_to_str (file_id);
if (file_id != 0) {
tracker_db_set_metadata (db_con, service, str_file_id, "File.Modified", str_mtime, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File.Size", str_size, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File.Name", name, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File.Path", path, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File.Format", mime, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Modified", str_mtime, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Size", str_size, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Name", name, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Path", path, TRUE, TRUE, TRUE);
tracker_db_set_metadata (db_con, service, str_file_id, "File:Format", mime, TRUE, TRUE, TRUE);
}
g_free (service);
......@@ -362,7 +362,7 @@ tracker_dbus_method_files_get_service_type (DBusRec *rec)
str_id = tracker_uint_to_str (file_id);
mime = tracker_get_metadata (db_con, "Files", str_id, "File.Format");
mime = tracker_get_metadata (db_con, "Files", str_id, "File:Mime");
result = tracker_get_service_type_for_mime (mime);
......@@ -889,7 +889,7 @@ tracker_dbus_method_files_get_metadata_for_files_in_folder (DBusRec *rec)
for (i = 0; i < n; i++) {
FieldDef *def;
const char *table;
char *table;
def = tracker_db_get_field_def (db_con, array[i]);
......@@ -898,18 +898,16 @@ tracker_dbus_method_files_get_metadata_for_files_in_folder (DBusRec *rec)
return;
}
if (def->type == DATA_INDEX_STRING) {
table = "ServiceIndexMetaData";
} else if (def->type == DATA_STRING) {
table = "ServiceMetaData";
} else if (def->type == DATA_INDEX_BLOB) {
table = "ServiceBlobMetaData";
if (def->multiple_values) {
table = g_strdup ("ServiceMetaDataDisplay");
} else {
table = "ServiceNumericMetaData";
table = tracker_get_metadata_table (def->type);
}
g_string_append_printf (sql, " LEFT OUTER JOIN %s M%d ON F.ID = M%d.ServiceID AND M%d.MetaDataID = %s ", table, i+1, i+1, i+1, def->id);
g_free (table);
tracker_db_free_field_def (def);
}
......
......@@ -22,7 +22,7 @@
#include "tracker-dbus-methods.h"
#include "tracker-dbus-keywords.h"
/*
static void
update_keywords_metadata (DBConnection *db_con, const char* service, const char *path, const char *name)
{
......@@ -66,6 +66,7 @@ update_keywords_metadata (DBConnection *db_con, const char* service, const char
keywords = g_string_free (words, FALSE);
tracker_db_update_keywords (db_con, service, id, keywords);
g_free (keywords);
......@@ -76,7 +77,7 @@ update_keywords_metadata (DBConnection *db_con, const char* service, const char
g_free (id);
}
*/
void
tracker_dbus_method_keywords_get_list (DBusRec *rec)
......@@ -129,7 +130,7 @@ tracker_dbus_method_keywords_get (DBusRec *rec)
DBConnection *db_con;
DBusError dbus_error;
DBusMessage *reply;
char *id, *uri, *service, *name, *path;
char *id, *uri, *service;
char **array;
char ***res;
int row_count;
......@@ -174,20 +175,9 @@ tracker_dbus_method_keywords_get (DBusRec *rec)
return;
}
g_free (id);
res = tracker_db_get_metadata_values (db_con, service, id, "DC:Keywords");
if (uri[0] == G_DIR_SEPARATOR) {
name = g_path_get_basename (uri);
path = g_path_get_dirname (uri);
} else {
name = tracker_get_vfs_name (uri);
path = tracker_get_vfs_path (uri);
}
res = tracker_exec_proc (db_con, "GetKeywords", 2, path, name);
g_free (name);
g_free (path);
g_free (id);
row_count = 0;
array = NULL;
......@@ -216,7 +206,7 @@ tracker_dbus_method_keywords_add (DBusRec *rec)
DBConnection *db_con;
DBusError dbus_error;
DBusMessage *reply;
char *id, *uri, *service, *name, *path;
char *id, *uri, *service;
char **array = NULL;
int row_count = 0;
......@@ -233,7 +223,8 @@ tracker_dbus_method_keywords_add (DBusRec *rec)
</method>
*/
dbus_error_init(&dbus_error);
dbus_error_init (&dbus_error);
if (!dbus_message_get_args (rec->message, NULL,
DBUS_TYPE_STRING, &service,
DBUS_TYPE_STRING, &uri,
......@@ -261,34 +252,22 @@ tracker_dbus_method_keywords_add (DBusRec *rec)
return;
}
tracker_log ("adding keywords to %s with id %s", uri, id);
g_free (id);
if (uri[0] == G_DIR_SEPARATOR) {
name = g_path_get_basename (uri);
path = g_path_get_dirname (uri);
} else {
name = tracker_get_vfs_name (uri);
path = tracker_get_vfs_path (uri);
}
if (array && (row_count > 0)) {
int i;
for (i = 0; i < row_count; i++) {
if (array[i]) {
tracker_exec_proc (db_con, "AddKeyword", 3, path, name, array[i]);
tracker_db_set_metadata (db_con, service, id, "DC:Keywords", array[i], TRUE, TRUE, FALSE);
}
}
}
dbus_free_string_array(array);
update_keywords_metadata (db_con, service, path, name);
g_free (name);
g_free (path);
tracker_log ("adding keywords to %s with id %s", uri, id);
g_free (id);
reply = dbus_message_new_method_return (rec->message);
......@@ -304,7 +283,7 @@ tracker_dbus_method_keywords_remove (DBusRec *rec)
DBConnection *db_con;
DBusError dbus_error;
DBusMessage *reply;
char *id, *uri, *service, *name, *path;
char *id, *uri, *service;
char **array;
int row_count = 0;
......@@ -351,32 +330,20 @@ tracker_dbus_method_keywords_remove (DBusRec *rec)
return;
}
g_free (id);
if (uri[0] == G_DIR_SEPARATOR) {
name = g_path_get_basename (uri);
path = g_path_get_dirname (uri);
} else {
name = tracker_get_vfs_name (uri);
path = tracker_get_vfs_path (uri);
}
if (array && (row_count > 0)) {
int i;
for (i = 0; i < row_count; i++) {
if (array[i]) {
tracker_exec_proc (db_con, "RemoveKeyword", 3, path, name, array[i]);
tracker_log ("deleting keyword %s from %s with ID %s", array[i], uri, id);
tracker_db_delete_metadata_value (db_con, service, id, "DC:Keywords", array[i], FALSE);
}
}
}
dbus_free_string_array (array);
update_keywords_metadata (db_con, service, path, name);
g_free (name);
g_free (path);
g_free (id);
reply = dbus_message_new_method_return (rec->message);
......@@ -392,7 +359,7 @@ tracker_dbus_method_keywords_remove_all (DBusRec *rec)
DBConnection *db_con;
DBusError dbus_error;
DBusMessage *reply;
char *id, *uri, *service, *name, *path;
char *id, *uri, *service;
g_return_if_fail (rec && rec->user_data);
......@@ -434,23 +401,10 @@ tracker_dbus_method_keywords_remove_all (DBusRec *rec)
return;
}
tracker_db_delete_metadata (db_con, service, id, "DC:Keywords");
g_free (id);
if (uri[0] == G_DIR_SEPARATOR) {
name = g_path_get_basename (uri);
path = g_path_get_dirname (uri);
} else {
name = tracker_get_vfs_name (uri);
path = tracker_get_vfs_path (uri);
}
tracker_exec_proc (db_con, "RemoveAllKeywords", 2, path, name);
update_keywords_metadata (db_con, service, path, name);
g_free (name);
g_free (path);
reply = dbus_message_new_method_return (rec->message);
dbus_connection_send (rec->connection, reply, NULL);
......@@ -516,26 +470,31 @@ tracker_dbus_method_keywords_search (DBusRec *rec)
return;
}
str_words = g_string_new (array[0]);
str_words = g_string_new ("");
g_string_append_printf (str_words, "'%s'", array[0]);
for (i = 1; i < row_count; i++) {
g_string_append_printf (str_words, ", %s", array[i]);
g_string_append_printf (str_words, ", '%s'", array[i]);
}
tracker_log ("executing keyword search on %s", str_words->str);
g_string_free (str_words, TRUE);
str_select = g_string_new (" Select distinct S.Path || '");
str_select = g_string_append (str_select, G_DIR_SEPARATOR_S);
str_select = g_string_append (str_select, "' || S.Name as EntityName from Services S ");
str_select = g_string_append (str_select, "' || S.Name as EntityName from Services S, ServiceKeywordMetaData M ");
char *related_metadata = tracker_get_related_metadata_names (db_con, "DC:Keywords");
str_where = g_string_new ("");
g_string_append_printf (str_where, " where S.ID = M.ServiceID and M.MetaDataID in (%s) and M.MetaDataValue in (%s) ", related_metadata, str_words->str);
g_free (related_metadata);
g_string_free (str_words, TRUE);
int smin, smax;
char *str_min, *str_max;
......@@ -551,16 +510,12 @@ tracker_dbus_method_keywords_search (DBusRec *rec)
str_max = tracker_int_to_str (smax);
g_string_printf (str_where, " where (S.ServiceTypeID between %s and %s) ", str_min, str_max);
g_string_append_printf (str_where, " and (S.ServiceTypeID between %s and %s) ", str_min, str_max);
g_free (str_min);
g_free (str_max);
for (i = 0; i < row_count; i++) {
g_string_append_printf (str_select, " INNER JOIN ServiceKeywords K%d on S.ID = K%d.ServiceID ", i, i);
g_string_append_printf (str_where, " And K%d.Keyword = '%s' ", i, array[i]);
}
g_string_append_printf (str_where, " Limit %d,%d", offset, limit);
......@@ -568,6 +523,7 @@ tracker_dbus_method_keywords_search (DBusRec *rec)
query_where = g_string_free (str_where, FALSE);
query = g_strconcat (query_sel, query_where, NULL);
tracker_log (query);
res = tracker_exec_sql (db_con, query);
g_free (query_sel);
......
......@@ -97,13 +97,7 @@ tracker_dbus_method_metadata_set (DBusRec *rec)
value = values[i];
if (!meta || strlen (meta) < 3 || (strchr (meta, '.') == NULL) ) {
tracker_set_error (rec, "Metadata type name %s is invalid. All names must be in the format 'class.name' ", meta);
g_free (id);
return;
}
if (strcmp (meta, "File.Keywords") == 0) {
tracker_set_error (rec, "File.Keywords can only be set from the Keywords Interface");
tracker_set_error (rec, "Metadata type name %s is invalid. All names must be registered in tracker", meta);
g_free (id);
return;
}
......@@ -133,7 +127,6 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
GString *sql;
char ***res;
char **date_array;
const char *table;
g_return_if_fail (rec && rec->user_data);
......@@ -227,7 +220,7 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
for (i = 0; i < key_count; i++) {
FieldDef *def;
char *metadata;
char *metadata, *table;
metadata = keys[i];
......@@ -235,16 +228,13 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
if (def) {
if (def->type == DATA_INDEX_STRING) {
table = "ServiceIndexMetaData";
} else if (def->type == DATA_STRING) {
table = "ServiceMetaData";
} else if (def->type == DATA_INDEX_BLOB) {
table = "ServiceBlobMetaData";
if (def->multiple_values) {
table = g_strdup ("ServiceMetaDataDisplay");
} else {
table = "ServiceNumericMetaData";
table = tracker_get_metadata_table (def->type);
}
} else {
tracker_set_error (rec, "Invalid or non-existant metadata type %s was specified", metadata);
......@@ -256,6 +246,8 @@ tracker_dbus_method_metadata_get (DBusRec *rec)
g_string_append_printf (sql, " LEFT OUTER JOIN %s M%d ON M%d.ServiceID = F.ID AND M%d.MetaDataID = %s ", table, table_count, table_count, table_count, def->id);
g_free (table);
tracker_db_free_field_def (def);
}
......
......@@ -335,7 +335,7 @@ tracker_dbus_method_search_files_by_text (DBusRec *rec)
/*
<!-- searches all file based entities that match the specified search_text.
Returns dict/hashtable with the uri as key and the following fields as the variant part in order: file service category, File.Format, File.Size, File.Rank, File.Modified
Returns dict/hashtable with the uri as key and the following fields as the variant part in order: file service category, File:Format, File:Size, File:Rank, File:Modified
If group_results is True then results are sorted and grouped by service type.
-->
<method name="FilesByText">
......@@ -436,7 +436,8 @@ tracker_dbus_method_search_metadata (DBusRec *rec)
return;
}
res = tracker_db_search_metadata (db_con, service, field, text, offset, limit);
// res = tracker_db_search_metadata (db_con, service, field, text, offset, limit);
res = NULL;
array = NULL;
......
......@@ -199,9 +199,9 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
/* update db so that fileID reflects new uri */
tracker_db_update_file_move (main_thread_db_con, moved_from_info->file_id, path, name, moved_from_info->indextime);
/* update File.Path and File.Filename metadata */
tracker_db_set_metadata (main_thread_db_con, "Files", str_file_id, "File.Path", path, TRUE, TRUE, TRUE);
tracker_db_set_metadata (main_thread_db_con, "Files", str_file_id, "File.Name", name, TRUE, TRUE, TRUE);
/* update File:Path and File:Filename metadata */
tracker_db_set_metadata (main_thread_db_con, "Files", str_file_id, "File:Path", path, TRUE, TRUE, TRUE);
tracker_db_set_metadata (main_thread_db_con, "Files", str_file_id, "File:Name", name, TRUE, TRUE, TRUE);
g_free (str_file_id);
g_free (name);
......@@ -228,7 +228,7 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
tracker_add_poll_dir (moved_to_info->uri);
}
/* update all changed File.Path metadata */
/* update all changed File:Path metadata */
tracker_exec_proc (main_thread_db_con, "UpdateFileMovePath", 2, moved_to_info->uri, moved_from_info->uri);
......@@ -266,7 +266,7 @@ process_event (const char *uri, gboolean is_dir, TrackerChangeAction action, gui
tracker_log ("moving subfolder %s to %s", dir_name, new_path);
/* update all changed File.Path metadata for all files in this subfolder*/
/* update all changed File:Path metadata for all files in this subfolder*/
tracker_exec_proc (main_thread_db_con, "UpdateFileMovePath", 2, new_path, dir_name);
/* update all subfolders and contained files to new path */
......@@ -523,7 +523,7 @@ process_inotify_events (void)
if (!tracker_ignore_file (file_utf8_uri)) {
process_event (str, tracker_is_directory (file_utf8_uri), action_type, cookie);
process_event (str, tracker_is_directory (str), action_type, cookie);
}
......
......@@ -66,8 +66,34 @@ delimit_utf8_string (const gchar *str)
return g_string_free (strs, FALSE);
}
/* check word either contains at least one alpha char or is a number of at least 5 consecutive digits (we want to index meaningful numbers only like telephone no.s, bank accounts, ISBN etc) */
static gboolean
numbered_word_is_valid (const char *word)
{
const char *p;
gunichar c;
int i = 0;
for (p = word; *p; p = g_utf8_next_char (p)) {
i++;
c = g_utf8_get_char (p);
if (g_unichar_isalpha (c) ) {
return TRUE;
}
if (!g_unichar_isdigit (c) ) {
return FALSE;
}
}
return (i > 4);
/* check word starts with alpha char or underscore */
}
/* check word starts with alphanumeric char or underscore and only numbers of 5 or more digits are indexed */
static gboolean
word_is_valid (const char *word)
{
......@@ -75,6 +101,10 @@ word_is_valid (const char *word)
c = g_utf8_get_char (word);
if (g_unichar_isalnum (c)) {