HashN

The HashN parameter specifies a Lua script to use for family hashing. The script should insert an MD5 field into the document, which is a hash of the document’s unique fields. To use this you must set ImportHashFamilies=true.

If the Lua script returns false then the hash is calculated from the whole of the original document (it does not matter whether the document is text or binary). Your script should return true only when it has set a field called "MD5" containing the hash to use for the document.

In the example below, hash.lua is used to generate the hash for each document. An example hash.lua is given below:

function handler(document)
	if document:getFieldValue("MAIL") == "TRUE" then
		local toHash =
		  allValues(document, "To" ) .. "||" ..
		  allValues(document, "From" ) .. "||" ..
		  allValues(document, "Subject" ) .. "||" ..
		  allValues(document, "Sent" );

		document:addField( "MD5", hash_string( toHash, "MD5" ) );
		return true;
	end
	
	return false;
end

function allValues(document, fieldName)
	return table.concat({ document:getFieldValues(fieldName) }, ";");
end

When this script is used, if the document has a field called "MAIL" set to "TRUE" then the hash is generated from the "To", "From", "Subject" and "Sent" fields. For all other items the whole document is used to generate the hash.

Type: String
Default: None
Required: No
Configuration Section: ImportTasks
Example: Hash0=Lua:hash.lua
See Also

ImportHashFamilies
ImportFamilyRootExcludeFmtCSV


_HP_HTML5_bannerTitle.htm