ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMKnowledgeGraphQueryDefinition Class
Members Example

In This Topic
    CIMKnowledgeGraphQueryDefinition Class
    In This Topic
    Represents a Knowledge Graph Query Definition.
    Object Model
    CIMKnowledgeGraphQueryDefinition ClassCIMKnowledgeGraphQueryDefinition ClassCIMKnowledgeGraphQueryDefinition Class
    Syntax
    Example
    Retrieve Investigation Query Definitions
    {
      // access the currently active knowledge graph investigation view
      KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
      KnowledgeGraphInvestigation investigation = activeView?.Investigation;
      if (investigation != null)
      {
        await QueuedTask.Run(() =>
        {
          // get all the query defintiions
          var queries = investigation.GetAllQueryDefinitions();
    
          // get a specific query definition
          var myQuery = investigation.GetQueryDefinition("Query1");
        });
      }
    }
    Add Query Definition
    {
      var newQueryDefinition = new CIMKnowledgeGraphQueryDefinition();
      newQueryDefinition.Name = "Query1";
      newQueryDefinition.ProvenanceBehavior = ProvenanceBehavior.Include;
      newQueryDefinition.OpenCypherQuery = "MATCH (n) RETURN n LIMIT 10\"";     // return the first 10 entities
    
      // access the currently active knowledge graph investigation view
      KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
      KnowledgeGraphInvestigation investigation = activeView?.Investigation;
      if (investigation != null)
      {
        await QueuedTask.Run(() =>
        {
          // add the new query defintiion
          investigation.AddQueryDefinition(newQueryDefinition);
        });
      }
    }
    Update Query Definition
    {
      // access the currently active knowledge graph investigation view
      KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
      KnowledgeGraphInvestigation investigation = activeView?.Investigation;
      if (investigation != null)
      {
        await QueuedTask.Run(() =>
        {
          // return the first 20 entities
          var newOpenCypherQuery = "MATCH (n) RETURN n LIMIT 20\"";
    
          // update the open cypher query for a query definition
          investigation.UpdateQueryDefinition("Query1", newOpenCypherQuery);
    
    
          // or update other properties
          var myQuery = investigation.GetQueryDefinition("Query1");
          if (myQuery != null)
          {
            myQuery.ProvenanceBehavior = ProvenanceBehavior.Exclude;
            myQuery.OpenCypherQuery = "MATCH (n) RETURN n LIMIT 30\"";
    
            investigation.UpdateQueryDefinition(myQuery);
          }
        });
      }
    }
    Rename a Query Definition
    {
      // access the currently active knowledge graph investigation view
      KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
      KnowledgeGraphInvestigation investigation = activeView?.Investigation;
      if (investigation != null)
      {
        await QueuedTask.Run(() =>
        {
          // rename the query definition
          investigation.RenameQueryDefinition("Query1", "EntityQuery");
        });
      }
    }
    Delete a Query Definition
    {
      // access the currently active knowledge graph investigation view
      KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
      KnowledgeGraphInvestigation investigation = activeView?.Investigation;
      if (investigation != null)
      {
        await QueuedTask.Run(() =>
        {
          // delete the query definition
          investigation.DeleteQueryDefinition("Query1");
        });
      }
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CIM.CIMObject
          ArcGIS.Core.CIM.CIMKnowledgeGraphQueryDefinition

    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.3 or higher.
    See Also