MARKLOGIC: Is it possible to use more than 1 columns from a CSV file when generating URI ID during data ingestion in MarkLogic?

江枫思渺然 提交于 2020-01-21 19:13:02

问题


I am quite new to MarkLogic and I am not sure how to best deal with the challenge I have right now.

I have a CSV file exported from a table that will be ingested to MarkLogic database. Now the source table uses 4 columns as its unique primary key combination.

In MarkLogic, by default, only one column from CSV file can be used as the URI ID.

My question is, is it possible to use more than 1 columns from a CSV file as the URI ID during data ingestion in MarkLogic? If yes, is this feature or setting available in data hub? If it is not possible, what is usually the best practice for this in MarkLogic?

I know that one possible work around is to create a new column combining the data from 4 primary key columns and use it as the URI ID.

Thanks in advanced for the help :)


回答1:


You can use MLCP Transforms to transform both the content value, and the uri. It gets a hash object $content containing both. Update its values as desired, and return the updated hash object. Something like:

declare function example:transform(
  $content as map:map,
  $context as map:map
) as map:map*
{
  let $record := map:get($content, "value")
  let $uri := $record/prop1 || $record/prop2 || $record/prop3 
  let $_ := map:put($content, "uri", $uri)
  return $content
};

You can use such MLCP transforms in marklogic-data-hub as well.

HTH!



来源:https://stackoverflow.com/questions/49046296/marklogic-is-it-possible-to-use-more-than-1-columns-from-a-csv-file-when-genera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!