索引

8.1 创建索引

  • Ultipa 具备完全自主研发的 fulltext 全文搜索引擎。 可以针对数据中的长文本进行高效快速的搜索,不仅方便了对元数据的检索,还适用于其他各类图搜索,如 AB, Khop 或者模板等。

  • 查看索引

    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.showIndex()
    print(ret.toJSON())
    
  • 给点创建普通索引

    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.createIndex(ULTIPA_REQUEST.CreatIndex(node_property='name'))
    print(ret.toJSON())
    
  • 给边创建普通索引

    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.createIndex(ULTIPA_REQUEST.CreatIndex(edge_property='name'))
    print(ret.toJSON()
    
  • 创建全文索引

    • 创建全文索引需要传入属性名和全文索引的别名
    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.createFullTextIndex(ULTIPA_REQUEST.CreateFullTextIndex(
    		node_property='name',name='node_name'))
    print(ret.toJSON())
    

8.2 删除索引

  • 当不再使用索引,为了节省内存和磁盘,可以将其删除。

  • 删除点索引

    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.dropIndex(ULTIPA_REQUEST.DropIndex(node_property='name'))
    print(ret.toJSON())
    
  • 删除边索引

    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.dropIndex(ULTIPA_REQUEST.DropIndex(edge_property='name'))
    print(ret.toJSON())
    
  • 删除全文索引

    from ultipa import Connection,ULTIPA_REQUEST
    conn = Connection(host='host:port', username="root", password="root")
    ret = conn.dropFullTextIndex(ULTIPA_REQUEST.DropFullTextIndex(name='node_name'))
    print(ret.toJSON())