

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# OpenSearch 데이터를 위한 Neptune 데이터 모델
<a name="full-text-search-model"></a>

Amazon Neptune에서는 통합 JSON 문서 구조를 사용하여 SPARQL 및 Gremlin 데이터 둘 모두 OpenSearch Service에 저장합니다. OpenSearch의 각 문서는 엔터티에 해당하며 해당 엔터티에 대한 모든 관련 정보를 저장합니다. Gremlin의 경우 버텍스 및 엣지가 엔터티로 간주되므로, 해당 OpenSearch 문서에 버텍스, 레이블 및 속성에 대한 정보가 있습니다. SPARQL의 경우 주체가 엔터티로 간주될 수 있으므로, 해당 OpenSearch 문서에 한 문서의 모든 조건자-객체 페어에 대한 정보가 있습니다.

**참고**  
Neptune에서 OpenSearch로의 복제 구현은 문자열 데이터만 저장합니다. 하지만 다른 데이터 유형을 저장하도록 수정할 수 있습니다.

통합 JSON 문서 구조는 다음과 같습니다.

```
{
  "entity_id": "Vertex Id/Edge Id/Subject URI",
  "entity_type": [List of Labels/rdf:type object value],
  "document_type": "vertex/edge/rdf-resource"
  "predicates": {
    "Property name or predicate URI": [
      {
        "value": "Property Value or Object Value",
        "graph": "(Only for Sparql) Named Graph Quad is present"
        "language": "(Only for Sparql) rdf:langString"
      },
      {
        "value": "Property Value 2/ Object Value 2",
      }
    ]
  }
}
```

****
+ `entity_id` – 문서를 나타내는 엔터티 고유 ID입니다.
  + SPARQL의 경우, 이는 주체 URI입니다.
  + Gremlin의 경우, 이는 `Vertex_ID` 또는 `Edge_ID`입니다.
+ `entity_type` – 버텍스 또는 엣지에 대한 하나 이상의 레이블 또는 주체에 대한 0개 이상의 `rdf:type` 조건자 값을 나타냅니다.
+ `document_type` – 현재 문서가 버텍스, 엣지 또는 rdf-리소스를 나타내는지 여부를 지정하는 데 사용됩니다.
+ `predicates` – Gremlin의 경우, 버텍스 또는 엣지에 대한 속성 및 값을 저장합니다. SPARQL의 경우, 조건자-객체 페어를 저장합니다.

  속성 이름은 OpenSearch에서 `properties.name.value` 형식을 따릅니다. 쿼리하려면 해당 양식으로 이름을 지정해야 합니다.
+ `value ` – Gremlin에 대한 속성 값 또는 SPARQL에 대한 객체 값입니다.
+ `graph` – SPARQL에 대한 명명된 그래프입니다.
+ `language` – SPARQL의 `rdf:langString` 리터럴에 대한 언어 태그입니다.

## 샘플 SPARQL OpenSearch 문서
<a name="full-text-search-model-sparql-example"></a>

**Data**

```
@prefix dt:   <http://example.org/datatype#> .
@prefix ex:   <http://example.org/> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

ex:simone   rdf:type     ex:Person                    ex:g1
ex:michael  rdf:type     ex:Person                    ex:g1
ex:simone   ex:likes     "spaghetti"                  ex:g1

ex:simone   ex:knows     ex:michael                   ex:g2   # Not stored in ES
ex:simone   ex:likes     "spaghetti"                  ex:g2
ex:simone   ex:status    "La vita è un sogno"@it      ex:g2

ex:simone   ex:age       "40"^^xsd:int                DG      # Not stored in ES
ex:simone   ex:dummy     "testData"^^dt:newDataType   DG      # Not stored in ES
ex:simone   ex:hates     _:bnode                              # Not stored in ES
_:bnode     ex:means     "coding"                     DG      # Not stored in ES
```

**문서**

```
{
  "entity_id": "http://example.org/simone",
  "entity_type": ["http://example.org/Person"],
  "document_type": "rdf-resource"
  "predicates": {
    "http://example.org/likes": [
      {
        "value": "spaghetti",
        "graph": "http://example.org/g1"
      },
      {
        "value": "spaghetti",
        "graph": "http://example.org/g2"
      }
    ]
    "http://example.org/status": [
      {
        "value": "La vita è un sogno",
        "language": "it"       // Only present for rdf:langString
      }
    ]
  }
}
```

```
{
  "entity_id" : "http://example.org/michael",
  "entity_type" : ["http://example.org/Person"],
  "document_type": "rdf-resource"
}
```

## 샘플 Gremlin OpenSearch 문서
<a name="full-text-search-model-gremlin-example"></a>

**Data**

```
# Vertex 1
simone   label    Person       <== Label
simone   likes    "spaghetti"  <== Property
simone   likes    "rice"       <== Property
simone   age      40           <== Property

# Vertex 2
michael  label    Person       <== Label

# Edge 1
simone  knows     michael      <== Edge
e1      updated  "2019-07-03"  <== Edge Property
e1      through  "company"     <== Edge Property
e1      since     10           <== Edge Property
```

** 문서**

```
{
  "entity_id": "simone",
  "entity_type": ["Person"],
  "document_type": "vertex",
  "predicates": {
    "likes": [
      {
        "value": "spaghetti"
      },
      {
        "value": "rice"
      }
    ]
  }
}
```

```
{
  "entity_id" : "michael",
  "entity_type" : ["Person"],
  "document_type": "vertex"
}
```

```
{
  "entity_id": "e1",
  "entity_type": ["knows"],
  "document_type": "edge"
  "predicates": {
    "through": [
      {
        "value": "company"
      }
    ]
  }
}
```