Nosql-neo4j-Cypher 函數(shù) 概要

目錄: [TOC]

Cypher函數(shù)概要

  • Cypher函數(shù)輸入為null浸须,輸出也為null
  • 函數(shù)輸入是字符串時刮吧,輸入的是unicode編碼的字符,而不是char[]

斷言函數(shù)Predicate functions

  • 返回ture或者false
Function Description
all() Tests whether the predicate holds for all elements in a list.
any() Tests whether the predicate holds for at least one element in a list.
exists() Returns true if a match for the pattern exists in the graph, or if the specified property exists in the node, relationship or map.
none() Returns true if the predicate holds for no element in a list.
single() Returns true if the predicate holds for exactly one of the elements in a list.

標(biāo)量函數(shù)Scalar functions

  • 返回單個值
Function Description
coalesce() Returns the first non-null value in a list of expressions
endNode() Returns the end node of a relationship.
head() ** Returns the first element** in a list.
id() ** Returns the id of a relationship or node**.
last() Returns the last element in a list.
length() Returns the length of a path.
properties() Returns a map containing all the properties of a node or relationship.
randomUUID() Returns a string value corresponding to a randomly-generated UUID.
size() Returns the number of items in a list.
size() applied to pattern expression Returns the number of sub-graphs matching the pattern expression.
size() applied to string Returns the number of Unicode characters in a string.
startNode() Returns the start node of a relationship.
timestamp() Returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
toBoolean() Converts a string value to a boolean value.
toFloat() Converts an integer or string value to a floating point number.
toInteger() Converts a floating point or string value to an integer value.
type() Returns the string representation of the relationship type.

聚合函數(shù)Aggregating functions

Function Description
avg() - Numeric values Returns the average of a set of numeric values.
avg() - Durations Returns the average of a set of Durations.
collect() Returns a list containing the values returned by an expression.
count() Returns the number of values or rows.
max() Returns the maximum value in a set of values.
min() Returns the minimum value in a set of values.
percentileCont() Returns the percentile of a value over a group using linear interpolation.
percentileDisc() Returns the nearest value to the given percentile over a group using a rounding method.
stDev() Returns the standard deviation for the given value over a group for a sample of a population.
stDevP() Returns the standard deviation for the given value over a group for an entire population.
sum() - Numeric values Returns the sum of a set of numeric values.
sum() - Durations Returns the sum of a set of Durations.

返回List函數(shù)List functions

Function Description
keys() Returns a list containing the string representations for all the property names of a node, relationship, or map.
labels() Returns a list containing the string representations for all the labels of a node.
nodes() Returns a list containing all the nodes in a path.
range() Returns a list comprising all integer values within a specified range.
reduce() Runs an expression against individual elements of a list, storing the result of the expression in an accumulator.
relationships() Returns a list containing all the relationships in a path.
reverse() Returns a list in which the order of all elements in the original list have been reversed.
tail() Returns all but the first element in a list.

數(shù)值函數(shù)numeric functions

Function Description
abs() Returns the absolute value of a number.
ceil() Returns the smallest floating point number that is greater than or equal to a number and equal to a mathematical integer.
floor() Returns the largest floating point number that is less than or equal to a number and equal to a mathematical integer.
rand() Returns a random floating point number in the range from 0 (inclusive) to 1 (exclusive); i.e. [0,1).
round() Returns the value of a number rounded to the nearest integer.
sign() Returns the signum of a number: 0 if the number is 0, -1 for any negative number, and 1 for any positive number.

對數(shù)函數(shù)logarithmic functions

Function Description
e() Returns the base of the natural logarithm, e.
exp() Returns e^n, where e is the base of the natural logarithm, and n is the value of the argument expression.
log() Returns the natural logarithm of a number.
log10() Returns the common logarithm (base 10) of a number.
sqrt() Returns the square root of a number.

三角函數(shù)trigonometric functions

Function Description
acos() Returns the arccosine of a number in radians.
asin() Returns the arcsine of a number in radians.
atan() Returns the arctangent of a number in radians.
atan2() Returns the arctangent2 of a set of coordinates in radians.
cos() Returns the cosine of a number.
cot() Returns the cotangent of a number.
degrees() Converts radians to degrees.
haversin() Returns half the versine of a number.
pi() Returns the mathematical constant pi.
radians() Converts degrees to radians.
sin() Returns the sine of a number.
tan() Returns the tangent of a number.

字符串函數(shù)String functions

Function Description
left() Returns a string containing the specified number of leftmost characters of the original string.
lTrim() Returns the original string with leading whitespace removed.
replace() Returns a string in which all occurrences of a specified string in the original string have been replaced by another (specified) string.
reverse() Returns a string in which the order of all characters in the original string have been reversed.
right() Returns a string containing the specified number of rightmost characters of the original string.
rTrim() Returns the original string with trailing whitespace removed.
split() Returns a list of strings resulting from the splitting of the original string around matches of the given delimiter.
substring() Returns a substring of the original string, beginning with a 0-based index start and length.
toLower() Returns the original string in lowercase.
toString() Converts an integer, float, boolean or temporal type (i.e. Date, Time, LocalTime, DateTime, LocalDateTime or Duration) value to a string.
toUpper() Returns the original string in uppercase.
trim() Returns the original string with leading and trailing whitespace removed.

時間函數(shù)Temporal functions

Function Description
date() Returns the current Date.
date.transaction() Returns the current Date using the transaction clock.
date.statement() Returns the current Date using the statement clock.
date.realtime() Returns the current Date using the realtime clock.
date({year [, month, day]}) Returns a calendar (Year-Month-Day) Date.
date({year [, week, dayOfWeek]}) Returns a week (Year-Week-Day) Date.
date({year [, quarter, dayOfQuarter]}) Returns a quarter (Year-Quarter-Day) Date.
date({year [, ordinalDay]}) Returns an ordinal (Year-Day) Date.
date(string) Returns a Date by parsing a string.
date({map}) Returns a Date from a map of another temporal value’s components.
date.truncate() Returns a Date obtained by truncating a value at a specific component boundary. Truncation summary.
datetime() Returns the current DateTime.
datetime.transaction() Returns the current DateTime using the transaction clock.
datetime.statement() Returns the current DateTime using the statement clock.
datetime.realtime() Returns the current DateTime using the realtime clock.
datetime({year [, month, day, …]}) Returns a calendar (Year-Month-Day) DateTime.
datetime({year [, week, dayOfWeek, …]}) Returns a week (Year-Week-Day) DateTime.
datetime({year [, quarter, dayOfQuarter, …]}) Returns a quarter (Year-Quarter-Day) DateTime.
datetime({year [, ordinalDay, …]}) Returns an ordinal (Year-Day) DateTime.
datetime(string) Returns a DateTime by parsing a string.
datetime({map}) Returns a DateTime from a map of another temporal value’s components.
datetime({epochSeconds}) Returns a DateTime from a timestamp.
datetime.truncate() Returns a DateTime obtained by truncating a value at a specific component boundary. Truncation summary.
localdatetime() Returns the current LocalDateTime.
localdatetime.transaction() Returns the current LocalDateTime using the transaction clock.
localdatetime.statement() Returns the current LocalDateTime using the statement clock.
localdatetime.realtime() Returns the current LocalDateTime using the realtime clock.
localdatetime({year [, month, day, …]}) Returns a calendar (Year-Month-Day) LocalDateTime.
localdatetime({year [, week, dayOfWeek, …]}) Returns a week (Year-Week-Day) LocalDateTime.
localdatetime({year [, quarter, dayOfQuarter, …]}) Returns a quarter (Year-Quarter-Day) DateTime.
localdatetime({year [, ordinalDay, …]}) Returns an ordinal (Year-Day) LocalDateTime.
localdatetime(string) Returns a LocalDateTime by parsing a string.
localdatetime({map}) Returns a LocalDateTime from a map of another temporal value’s components.
localdatetime.truncate() Returns a LocalDateTime obtained by truncating a value at a specific component boundary. Truncation summary.
localtime() Returns the current LocalTime.
localtime.transaction() Returns the current LocalTime using the transaction clock.
localtime.statement() Returns the current LocalTime using the statement clock.
localtime.realtime() Returns the current LocalTime using the realtime clock.
localtime({hour [, minute, second, …]}) Returns a LocalTime with the specified component values.
localtime(string) Returns a LocalTime by parsing a string.
localtime({time [, hour, …]}) Returns a LocalTime from a map of another temporal value’s components.
localtime.truncate() Returns a LocalTime obtained by truncating a value at a specific component boundary. Truncation summary.
time() Returns the current Time.
time.transaction() Returns the current Time using the transaction clock.
time.statement() Returns the current Time using the statement clock.
time.realtime() Returns the current Time using the realtime clock.
time({hour [, minute, …]}) Returns a Time with the specified component values.
time(string) Returns a Time by parsing a string.
time({time [, hour, …, timezone]}) Returns a Time from a map of another temporal value’s components.
time.truncate() Returns a Time obtained by truncating a value at a specific component boundary. Truncation summary.

duration函數(shù)

Function Description
duration({map}) Returns a Duration from a map of its components.
duration(string) Returns a Duration by parsing a string.
duration.between() Returns a Duration equal to the difference between two given instants.
duration.inMonths() Returns a Duration equal to the difference in whole months, quarters or years between two given instants.
duration.inDays() Returns a Duration equal to the difference in whole days or weeks between two given instants.
duration.inSeconds() Returns a Duration equal to the difference in seconds and fractions of seconds, or minutes or hours, between two given instants.

坐標(biāo)函數(shù)Spatial functions

Function Description
distance() Returns a floating point number representing the geodesic distance between any two points in the same CRS.
point() - Cartesian 2D Returns a 2D point object, given two coordinate values in the Cartesian coordinate system.
point() - Cartesian 3D Returns a 3D point object, given three coordinate values in the Cartesian coordinate system.
point() - WGS 84 2D Returns a 2D point object, given two coordinate values in the WGS 84 geographic coordinate system.
point() - WGS 84 3D Returns a 3D point object, given three coordinate values in the WGS 84 geographic coordinate system.

LOAD CSV functions

Function Description
linenumber() Returns the line number that LOAD CSV is currently using.
file() Returns the absolute path of the file that LOAD CSV is using.

User-defined functions

User-defined functions are written in Java, deployed into the database and are called in the same way as any other Cypher function. There are two main types of functions that can be developed and used:

Type Description Usage Developing
Scalar For each row the function takes parameters and returns a result Using UDF Extending Neo4j (UDF)
Aggregating Consumes many rows and produces an aggregated result Using aggregating UDF Extending Neo4j (Aggregating UDF)

本文使用 文章同步助手 同步

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末勾缭,一起剝皮案震驚了整個濱河市高镐,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌啤月,老刑警劉巖煮仇,帶你破解...
    沈念sama閱讀 207,113評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異谎仲,居然都是意外死亡浙垫,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,644評論 2 381
  • 文/潘曉璐 我一進(jìn)店門郑诺,熙熙樓的掌柜王于貴愁眉苦臉地迎上來夹姥,“玉大人,你說我怎么就攤上這事辙诞≌奘郏” “怎么了?”我有些...
    開封第一講書人閱讀 153,340評論 0 344
  • 文/不壞的土叔 我叫張陵飞涂,是天一觀的道長旦部。 經(jīng)常有香客問我祈搜,道長,這世上最難降的妖魔是什么士八? 我笑而不...
    開封第一講書人閱讀 55,449評論 1 279
  • 正文 為了忘掉前任容燕,我火速辦了婚禮,結(jié)果婚禮上婚度,老公的妹妹穿的比我還像新娘蘸秘。我一直安慰自己,他們只是感情好蝗茁,可當(dāng)我...
    茶點故事閱讀 64,445評論 5 374
  • 文/花漫 我一把揭開白布秘血。 她就那樣靜靜地躺著,像睡著了一般评甜。 火紅的嫁衣襯著肌膚如雪灰粮。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,166評論 1 284
  • 那天忍坷,我揣著相機與錄音粘舟,去河邊找鬼。 笑死佩研,一個胖子當(dāng)著我的面吹牛柑肴,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播旬薯,決...
    沈念sama閱讀 38,442評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼晰骑,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了绊序?” 一聲冷哼從身側(cè)響起硕舆,我...
    開封第一講書人閱讀 37,105評論 0 261
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎骤公,沒想到半個月后抚官,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,601評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡阶捆,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,066評論 2 325
  • 正文 我和宋清朗相戀三年凌节,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片洒试。...
    茶點故事閱讀 38,161評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡倍奢,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出垒棋,到底是詐尸還是另有隱情卒煞,我是刑警寧澤,帶...
    沈念sama閱讀 33,792評論 4 323
  • 正文 年R本政府宣布捕犬,位于F島的核電站跷坝,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏碉碉。R本人自食惡果不足惜柴钻,卻給世界環(huán)境...
    茶點故事閱讀 39,351評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望垢粮。 院中可真熱鬧贴届,春花似錦、人聲如沸蜡吧。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,352評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽昔善。三九已至元潘,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間君仆,已是汗流浹背翩概。 一陣腳步聲響...
    開封第一講書人閱讀 31,584評論 1 261
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留返咱,地道東北人钥庇。 一個月前我還...
    沈念sama閱讀 45,618評論 2 355
  • 正文 我出身青樓,卻偏偏與公主長得像咖摹,于是被迫代替她去往敵國和親评姨。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 42,916評論 2 344

推薦閱讀更多精彩內(nèi)容