87e9262001-06-22Martin Nilsson // This file is part of Roxen Search // Copyright © 2001 Roxen IS. All rights reserved. //
d1469b2001-08-21Johan Schön // $Id: Indexer.pmod,v 1.15 2001/08/21 14:21:28 js Exp $
87e9262001-06-22Martin Nilsson 
28d6b82001-08-08Martin Nilsson //!
d057542001-06-04Johan Schön void index_document(Search.Database.Base db,
4779302001-06-05Per Hedbor  string|Standards.URI uri, void|string language, mapping fields, mapping uri_anchors)
90f5642001-05-17Johan Schön {
57ab6d2001-05-26Per Hedbor  db->remove_document( uri, language );
d057542001-06-04Johan Schön  foreach(indices(fields), string field)
57ab6d2001-05-26Per Hedbor  {
d057542001-06-04Johan Schön  string f; if( strlen(f = fields[field] ) )
57ab6d2001-05-26Per Hedbor  {
4779302001-06-05Per Hedbor  array words=Search.Utils.tokenize_and_normalize( f );
d057542001-06-04Johan Schön  db->insert_words(uri, language, field, words );
57ab6d2001-05-26Per Hedbor  } }
90f5642001-05-17Johan Schön  // Tokenize any anchor fields
b7ef8a2001-06-26Johan Schön  // int source_hash=hash((string)uri)&0xf; // foreach(indices(uri_anchors|| ({ })), string link_uri) // { // array(string) words= // Search.Utils.tokenize_and_normalize(uri_anchors[link_uri]); // db->insert_words(link_uri, 0, "anchor", words, source_hash); // }
90f5642001-05-17Johan Schön }
d057542001-06-04Johan Schön 
28d6b82001-08-08Martin Nilsson //!
d057542001-06-04Johan Schön array(Standards.URI) filter_and_extract_links(Search.Database.Base db, string|Standards.URI uri, void|string language, string|Stdio.File data,
9707602001-06-06Per Hedbor  string content_type, mapping headers, string default_charset )
90f5642001-05-17Johan Schön { Search.Filter.Base filter=Search.get_filter(content_type); if(!filter) throw("No indexer for content type "+content_type);
9707602001-06-06Per Hedbor  Search.Filter.Base.Output filteroutput= filter->filter(uri, data, content_type, headers, default_charset);
d057542001-06-04Johan Schön  index_document(db, uri, language, filteroutput->fields, filteroutput->uri_anchors);
90f5642001-05-17Johan Schön  return filteroutput->links; }
28d6b82001-08-08Martin Nilsson //!
eac31a2001-05-31Johan Schön void remove_document(Search.Database.Base db,
d1469b2001-08-21Johan Schön  string|Standards.URI uri,
90f5642001-05-17Johan Schön  void|string language) { db->remove_document(uri, language); }