使用更简单的格式获取顶点

时间:2018-05-04 14:06:46

标签: gremlin tinkerpop3 janusgraph

有没有办法获得格式更简单的顶点列表? 目前,以下查询:

g.V().has(label, 'Quantity').has('text', '627 km');

返回如下对象:

{
   "id": 42545168,
   "label": "Quantity",
   "type": "vertex",
   "properties": {
       "sentence": [
       {
          "id": "pkbgi-pbw28-745",
          "value": "null"
       }
       ],
       "updated_text": [
       {
          "id": "pk9vm-pbw28-5j9",
          "value": "627 km"
       }
       ],[...]

当我得到一个边缘列表时,它的格式为更简单的格式:

g.E().has(label, 'locatedAt').has('out_entity_id','41573-41579');

返回:

{
  "id": "ozfnt-ip8o-2mtx-g8vs",
  "label": "locatedAt",
  "type": "edge",
  "inVLabel": "Location",
  "outVLabel": "Location",
  "inV": 758008,
  "outV": 872520,
  "properties": {
      "sentence": "Bolloré is a corporation (société anonyme) with a Board of Directors whose registered offi ce is located at Odet, 29500 Ergué-Gabéric in France.",
      "in_entity_id": "41544-41548",
      "score": "0.795793",
      "out_entity_id": "41573-41579"
  }
}

怎么样? 有没有办法以这种方式格式化顶点?

1 个答案:

答案 0 :(得分:-1)

我的建议是让您的查询返回整个顶点,返回您感兴趣的特定属性。例如,您感兴趣的顶点ID或某些选定属性或valueMap。否则你会得到什么基本上是一切。这与在SQL中尝试不执行“select *”但仅选择您真正关心的内容完全相同。

编辑添加一个返回匹配顶点ID的示例。

<nobr>
    <a target="framedetail" href="DetailServlet?com=s&amp;cname=Bank%20of%20America%2c%20National%20Association" onclick="s_objectID=&quot;https://www.example.com/item1 this.s_oc?this.s_oc(e):true">
        <img src="imgs/brcb.gif" width="8" height="8" alt="Commercial Bank" border="0">
        &nbsp;Bank of America, National Association
    </a>
    <br>
        &nbsp;&nbsp;&nbsp;Texas-United States
    <br>
    <a target="framedetail" href="DetailServlet?com=s&amp;cname=Bank%20of%20America%2c%20National%20Association" onclick="s_objectID=&quot;https://www.example.com/item2 this.s_oc?this.s_oc(e):true">
        <img src="imgs/brcb.gif" width="8" height="8" alt="Commercial Bank" border="0">
        &nbsp;Bank of America, National Association
    </a>
    <br>
        &nbsp;&nbsp;&nbsp;Illinois-United States
    <br>
</nobr>

会产生看起来像这样的结果

g.V().has(label, 'Quantity').has('text', '627 km').id().fold()