Hello. I tried to create a glossary term, associat...
# getting-started
m
Hello. I tried to create a glossary term, associate to a column, but I cannot find it. Here is the details
plus1 1
In https://demo.datahubproject.io/api/graphiql I created a GlossaryTerm
Copy code
mutation createGlossaryTerm {
  createGlossaryTerm (
    input: {
      name: "gt"
  	}
  )
}
I got
urn:li:glossaryTerm:99e749e8-f619-40c8-bf92-7efa21f6edf4
Then I associate the glossary term to a dataset
Copy code
mutation addGlossaryTerm {
  addTerm(
    input: {
      termUrn: "urn:li:glossaryTerm:99e749e8-f619-40c8-bf92-7efa21f6edf4"
      resourceUrn: "urn:li:dataset:(urn:li:dataPlatform:hive,SampleHiveDataset,PROD)"
      subResourceType: DATASET_FIELD
      subResource: "field_bar"
      
    }
  ) 
}
Query the dataset
Copy code
query dataset {
  dataset(
    urn: "urn:li:dataset:(urn:li:dataPlatform:hive,SampleHiveDataset,PROD)"
  ) {
    schemaMetadata {
      fields {
        fieldPath
        type
        nativeDataType
      }
    }
    editableSchemaMetadata {
      editableSchemaFieldInfo {
        fieldPath
        description
        glossaryTerms {
          terms {
            term {
              urn
            }
          }
        }
      }
    }
  }
}
I got
Copy code
{
  "data": {
    "dataset": {
      "schemaMetadata": {
        "fields": [
          {
            "fieldPath": "field_foo",
            "type": "BOOLEAN",
            "nativeDataType": "varchar(100)"
          },
          {
            "fieldPath": "field_bar",
            "type": "BOOLEAN",
            "nativeDataType": "boolean"
          }
        ]
      },
      "editableSchemaMetadata": {
        "editableSchemaFieldInfo": [
          ...
          {
            "fieldPath": "field_bar",
            "description": "filed_bar\n\n\n",
            "glossaryTerms": {
              "terms": [
                ...
                {
                  "term": {
                    "urn": "urn:li:glossaryTerm:99e749e8-f619-40c8-bf92-7efa21f6edf4"
                  }
                }
              ]
            }
          }
        ]
      }
    }
  },
  "extensions": {}
}
But when I search it
Copy code
query search {
  search(input: { query: "glossaryTerm:gt", start: 0, count: 10, type:DATASET}) {
    searchResults {
      entity {
        urn
      }
    }
  }
}
I got empty results. Do you know which step did I miss? Thanks!
Good morning @big-carpet-38439 Do you think it is an easy question for you? 😀 Thanks
I now know my gql is wrong
Copy code
query search {
  searchAcrossEntities(
    input: {query: "editedFieldGlossaryTerms:\"99e749e8-f619-40c8-bf92-7efa21f6edf4\"", start: 0, count: 10}
  ) {
    searchResults {
      entity {
        urn
      }
    }
  }
}
Then I will see the result. Thanks all the same
b
Got it - glad you were able to figure that out!
m
I read https://datahubproject.io/docs/metadata-modeling/extending-the-metadata-model/#searchable and it says
or tags directly applied to an entity via
tags:<tag_name>
However, when my queries are
Copy code
query: "terms:\"gt\""
It does not work cc @big-carpet-38439
b
So in this case we literally index this URN field!
And we also index the split URN
So in reality you'd need to put the ID of the glossary term in there
(Not the common name)
However, @green-football-43791 is working on an advanced search feature which will allow you to do this more advanced search predicates
m
Copy code
query: "terms:\"99e749e8-f619-40c8-bf92-7efa21f6edf4\"",
does not work
b
hm let me try
m
full query https://demo.datahubproject.io/api/graphiql
Copy code
query search {
  search(
    input: {
      query: "terms:\"99e749e8-f619-40c8-bf92-7efa21f6edf4\"", 
      type: DATASET
      start: 0, count: 10}
  ) {
    searchResults {
      entity {
        urn
      }
    }
  }
}
b
ok i've got it
fieldGlossaryTerms:\"afecfc57-7287-4139-bdbd-cfb81b116f2b\"
or
glossaryTerms:\"<id>\"
should work
m
Both of them do not work
b
really?
we are using them in the app
oops
if you are looking for editable terms
use this
editedFieldGlossaryTerms:\"afecfc57-7287-4139-bdbd-cfb81b116f2b\""
m
Yes. That works But go back to my previous question, what does terms mean here? https://datahubspace.slack.com/archives/CV2KB471C/p1662061555114769?thread_ts=1662008326.079209&amp;cid=CV2KB471C Since we cannot use terms to query
The context is I am creating my entity, I don't know what I should write
b
This is only referring to "tags" not terms
I mean in the doc
m
Then how do we use "terms". Should it be consistent with something otherwise the search won't work?
b
"terms" is not a valid filter
However, glossaryTerms is
m
So that I can replace "terms" with any words?
b
So basically this is driven by those @Searchable annotations
If a field has a searchable you can generally use the field's name
fieldName: x
b
Yes!
terms is a field name of glossary terms
The part about /terms/*/...
Is referring to a nested field path:
m
Thank you 🙏