Skip to main content

Index and Annotate Document - Examples

Abstract

Index and Annotate Document - Examples

This section contains examples for using the GraphSearch/api/content/create call to advantage.

Index a Document and Create Annotations Automatically

The concept extraction process can be automatic, where the 'text' field in the post body will be annotated with concepts of the thesaurus used by GraphSearch with the PoolParty concept extraction service, if dynUris is not provided in the request body.

The following is a sample request:

Example request

{
    "identifier":"https://en.wikipedia.org/wiki/Mojito",
    "title":"Mojito",
    "author":"Test Author",
    "date":"2016-12-22",
    "text":"Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]"
}

Accordingly, a new record is inserted into the search index with content as follows:

Resulting Record

{
        "dyn_lit_author": [
          "Test Author"
        ],
        "date": "2016-12-22T00:00:00Z",
        "identifier": "https://en.wikipedia.org/wiki/Mojito",
        "source": "https://en.wikipedia.org/wiki/Mojito",
        "dyn_flt_sentiment": 0.7368421,
        "description": "Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]",
        "title": "Mojito",
        "type": "User",
        "dyn_uri_518": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/641"
        ],
        "dyn_uri_518_transitive": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/641",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/618",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/617"
        ],
        "dyn_uri_all_concepts": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/641",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/876",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/853",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/854"
        ],
        "dyn_uri_839": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/876",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/853",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/854"
        ],
        "dyn_uri_839_transitive": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/846",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/862",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/876",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/873",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/853",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/846",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/854",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/846"
        ],
        "dyn_txt_content": "Mojito\n Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]",
        "_version_": 1554432345008767000
      }

Note

The fields in the form of dyn_uri_* represent optional annotations.

For more information about dynamic fields in GraphSearch, see GraphSearch API.

Index a Document and Create Annotations Manually

Annotations can also be attached to the content directly in the request, which will no longer trigger the concept extraction process.

The attribute dynUris is used to specify annotations in a list of key value pairs where

  • keys are identifiers of search fields in GraphSearch, which represent concept schemes in the thesaurus, and

  • values are the URI of concepts inside the corresponding concept schemes annotating the document to be posted.

Example Request

{
    "identifier":"https://en.wikipedia.org/wiki/Mojito",
    "title":"Mojito",
    "author":"test",
    "date":"2016-12-22",
    "text":"Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]",
    "useExtraction":"false",
    "facets":{
        "dyn_uri_839":[
                "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
                "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863"]
    }
}

This annotates two concepts in the concept scheme http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/839 represented by dyn_uri_839, as shown here:

Resulting Annotated Concepts

{
        "dyn_lit_author": [
          "test"
        ],
        "date": "2016-12-22T00:00:00Z",
        "identifier": "https://en.wikipedia.org/wiki/Mojito",
        "source": "https://en.wikipedia.org/wiki/Mojito",
        "dyn_flt_sentiment": 0,
        "description": "Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]",
        "title": "Mojito",
        "type": "User",
        "dyn_uri_839": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863"
        ],
        "dyn_uri_839_transitive": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/846",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/862"
        ],
        "dyn_uri_all_concepts": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863"
        ],
        "dyn_txt_content": "Mojito\n Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]",
        "_version_": 1554433473276543000
      }
Index a Document and Attach Additional Custom Attributes

In the case content specific custom attributes should be returned as search results when using search service, you also have to provide the custom attributes in the request body during the content creation and update process.

The field customAttributes is custom attributes per document in a list of key value pairs, where

  • keys are identifiers of custom search fields and

  • values are the attribute values.

Note

You have to define the custom search fields in the GraphSearch configuration interface before using it in the search index.

This is an example request:

Example Request

{
    "identifier":"https://en.wikipedia.org/wiki/Mojito",
    "title":"Mojito",
    "author":"test",
    "date":"2016-12-22",
    "text":"Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]",
    "facets":{
        "dyn_uri_839":[
                "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
                "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863"],
        "dyn_lit_countryOfOrigin":[
                "Cuba"
                ]
    }
}

It will create custom attributes for the given document, and result in the following record in the search index:

Result

{
        "dyn_lit_author": [
          "test"
        ],
        "date": "2016-12-22T00:00:00Z",
        "identifier": "https://en.wikipedia.org/wiki/Mojito",
        "source": "https://en.wikipedia.org/wiki/Mojito",
        "dyn_flt_sentiment": 0,
        "description": "Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]",
        "title": "Mojito",
        "type": "User",
        "dyn_lit_countryOfOrigin": [
          "Cuba"
        ],
        "dyn_uri_839": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863"
        ],
        "dyn_uri_839_transitive": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/846",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/862"
        ],
        "dyn_uri_all_concepts": [
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/850",
          "http://e-learning.poolparty.biz/Cocktailtaxonomy_essentials/863"
        ],
        "dyn_txt_content": "Mojito\n Mojito is a traditional Cuban highball. Traditionally, a mojito is a cocktail that consists of five ingredients: white rum, sugar (traditionally sugar cane juice), lime juice, soda water, and mint.[1][2] The original Cuban recipe uses spearmint or yerba buena, a mint variety very popular on the island.[citation needed] Its combination of sweetness, refreshing citrus, and mint flavors is intended to complement the potent kick of the rum, and has made this clear highball a popular summer drink.[3][4] The cocktail has a relatively low alcohol content (about 10 percent alcohol by volume). When preparing a mojito, lime juice is added to sugar (or syrup) and mint leaves. The mixture is then gently mashed with a muddler. The mint leaves should only be bruised to release the essential oils and should not be shredded.[5] Then rum is added and the mixture is briefly stirred to dissolve the sugar and to lift the mint leaves up from the bottom for better presentation. Finally, the drink is topped with crushed ice and sparkling soda water. Mint leaves and lime wedges are used to garnish the glass.[6] Mojito The mojito is one of the most famous rum-based highballs. There are several versions of the mojito.[7]",
        "_version_": 1554434404707729400
      }
Index a Web Resource

Textual Web resources identified by URLs can also be ingested and indexed with GraphSearch as a document.

Example:

There is a page on Wikipedia about Caipirinha and one wants to index it. Then instead of having the field text for the content, the field externalUrl is required for the URL of the Web resource, which will be crawled and ingested.

The request body for this example is as follows:

Example Request

{
    "identifier":"http://en.wikipedia.org/wiki/Caipirinha"
    "website":"https://en.wikipedia.org/wiki/Caipirinha",
    "title":"Caipirinha",
    "author":"test",
    "date":"2017-01-12"
}

This API creates a new entry in the search index for the given document.