This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "mappings": { | |
| "_doc": { | |
| "properties": { | |
| "_JOIN_": { // esse é o nome que vamos dar para o campo responsável por juntar os dados | |
| "type": "join", | |
| "relations": { | |
| "users": "posts" // aqui é onde definimos o grau de parentesco dos nossos documentos | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "id": 1, | |
| "name": "John Watson", | |
| "email": "john@watson.com", | |
| "created_at": "2018-05-28T04:28:28+03:00", | |
| "_JOIN_": "users" // como esse é um documento pai, usamos apenas o nome da relação "users" para campo join "_JOIN_" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "id": 2, | |
| "name": "John Lenon", | |
| "email": "john@lenon.com", | |
| "created_at": "2018-05-29T03:28:36+03:00", | |
| "_JOIN_": "users" // a mesma anotação simples para indicar que é um documento pai | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "title": "This is a user post 1...", | |
| "body": "This is a body...", | |
| "_JOIN_": { // o nosso campo join agora está recebendo um objeto | |
| "name": "posts", // informamos que o documento será indexado como "posts", que então será filho de "users" | |
| "parent": "1" // especificando o ID do documento pai (Esse será um post de John Watson). | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "title": "This is another user post 1", | |
| "body": "This is a body...", | |
| "_JOIN_": { | |
| "name": "posts", | |
| "parent": "1" // esse será um outro post do usuário John Watson | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "title": "This is a user post 2", | |
| "body": "This is a body...", | |
| "_JOIN_": { | |
| "name": "posts", | |
| "parent": "2" // aqui estamos especificando o ID do usuário "John Lenon" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "query": { | |
| "has_parent": { // aqui estamos o método has_parent, que efeturá a pesquisa com o pai especificado | |
| "parent_type": "users", // buscamos os documentos que tenham como pai, os documentos "users" | |
| "query": { | |
| "match_all": {} // buscando todos os resultados | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "query": { | |
| "has_parent": { | |
| "parent_type": "users", | |
| "query": { // as cláusulas utilizadas nesse objeto serão utilizadas para o documento pai | |
| "match": { | |
| "name": "Watson" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| import './index.css' | |
| class App extends Component { | |
| render() { | |
| return ( | |
| <div> | |
| {/* vazio, por enquanto */} | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import ReactDOM from 'react-dom' | |
| import App from './App' | |
| import registerServiceWorker from './registerServiceWorker' | |
| ReactDOM.render(<App />, document.getElementById('root')) | |
| registerServiceWorker() |