g.V().hasLabel('Person').count()
为我提供了数据库中存在的人物顶点数量,g.V().hasLabel('Person').range(10,15)
为我提供了一系列人物顶点。
但有没有办法将这两者合并为一个Gremlin查询?
这只是我的查询的简化版本,但我的实际查询是安静的复杂并重复这些遍历只是为了找到计数,似乎无效!
答案 0 :(得分:2)
我不建议在每个查询中执行完整的.uslugi >a{
color: #F00 !important;
font-size:16px !important;
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
#left,
#left ul,
#left ul li,
#left ul li a {
padding: 0;
list-style: none;
line-height: 1.5;
display: block;
position: relative;
cursor: pointer;
text-decoration: none;
color: #515151;
margin:0;
font-family: "Trebuchet MS", Helvetica, sans-serif;
font-size: 16px;
}
#left ul li a:hover{
color: #000;
background-color: rgba(47, 139, 182, 0.1);
}
.widget.widget_nav_menu li:before{
display: none;
}
#main-wrapper .widget li:hover{
background:none;
}
#left ul ul {
display: none;
margin: 0 10px;
}
#left ul ul li a {
cursor: pointer;
padding: 0 5px;
z-index: 1;
color: #344E83;
background: -moz-linear-gradient(right, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%);
background: -webkit-gradient(right top, left top, color-stop(0%, rgba(255,255,255,1)), color-stop(98%, rgba(255,255,255,0.91)), color-stop(100%, rgba(184,238,255,0.81)));
background: -webkit-linear-gradient(right, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%);
background: -o-linear-gradient(right, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%);
background: -ms-linear-gradient(right, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%);
background: linear-gradient(to left, rgba(255,255,255,1) 0%, rgba(255,255,255,0.91) 98%, rgba(184,238,255,0.81) 100%);
}
#left .menu-item-has-children > a:after {
content: "";
border-right: 10px solid transparent;
border-left: 10px solid transparent;
margin: 10px 13px 0 0;
border-top: 6px solid #5F5F5F;
position: absolute;
right: 0;
top: 0;
}
.holder{
border: 1px solid rgba(0, 0, 0, 0.14);
padding: 11px 26px;
z-index: 8;
position: absolute;
margin: 1px -3px 0 0;
right: 0;
background: none;
}
.holder:hover {
background: rgba(47, 139, 182, 0.1);
}
#left ul li.open > a,
#left ul li.active > a,
#left ul ul li:hover > a,
#left ul ul li.open > a,
#left ul ul li.active > a,
.current-page-ancestor a {
color: #4686E6;
background-color: rgba(47, 139, 182, 0.2);
}
#left ul ul li:first-child > a {
box-shadow: none;
}
#left ul ul ul li a {
padding-left: 30px;
}
@media (min-width:768px) and (max-width:979px){
.span3{
width:186px;
margin-left:0;
}
}
。而是将总数计算一次并将其缓存在您的应用程序中。
那就是说,无论如何你都可以这样做:
count()
<强>更新强>
在旧版本中,您可以尝试:
g.V().hasLabel('Person').aggregate('x').cap('x').
project('page3', 'total').by(range(local, 10, 15)).by(count(local))
答案 1 :(得分:1)
我刚刚意识到,我可以使用groovy和gremlin来实现我想要的。不确定这是多么优雅!
<div>
即使在我复杂的情况下,这也很有效。