Skip to main content

Web Service Method: Create Indexed Document

Abstract

Web Service Method: Create Indexed Document

Description

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

Note

This methods works only in search taxonomy-based search configurations (Solr, Elasticsearch).

Note

In order to find appropriate content with search services, you should extract and annotate uploaded content with concepts from the thesaurus in advance during content creation and update with /api/content/create and /api/content/update APIs.

URL: /GraphSearch/api/content/create

Request

Supported Method

POST

Content-Type

application/json

JSON Object for a Request

Attribute

Type

Required

Comment

author

String

true

Content author

context

String

false

Content context

date

Date

false

Content creation

facets

Map of String

false

Content map of manually created facets (SearchField, facets)

identifier

URL

true

Content URL/ID

language

String

false

Content language

searchSpaceId

String

true

Search Space Identifier

synchronize

boolean

false

Synchronize automatically. Set to false for bulk content push. Refresh manually.

text

String

false

Content text

title

String

true

Content title

useExtraction

boolean

false

Use extraction for tagging

website

URL

false

Content from external URL (web crawling)

Example Request
{
  "date" : "2017-01-27",
  "identifier" : "https://semantic-web.com/",
  "searchSpaceId" : "some searchSpaceId",
  "website" : "https://semantic-web.com/",
  "author" : "some author",
  "context" : "some context",
  "useExtraction" : false,
  "language" : "en",
  "text" : "some text",
  "title" : "All about Chuck Norris",
  "facets" : { },
  "synchronize" : true
}

Response

Content Type

text/plain

More examples find here: Index and Annotate Document - Examples

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.