Slide 1

Slide 1 text

S e a rc h e v e r y t h i n g b y A l e x a p o w e re d b y A W S J A W S - U G K o b e 2 0 1 8 / 1 1

Slide 2

Slide 2 text

H i d e t a k a O k a m o t o • Digitalcube Co. Ltd. • Alexa Campions • AWS Samurai 2017 in Japan

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

h t t p s : / / b i t . l y / 2 B 4 B p n D

Slide 7

Slide 7 text

· ͱ Ί A g e n d a • AlexaͰͷ୯ޠݕࡧ͸Amazon.SearchQuery • ElasticsearchͰݕࡧΛϒʔετ • SPARQL͸͍͍ͧ

Slide 8

Slide 8 text

A g e n d a • AlexaͰͷ୯ޠݕࡧ͸AMAZON.SearchQuery • ElasticsearchͰݕࡧΛϒʔετ • SPARQL͸͍͍ͧ

Slide 9

Slide 9 text

– h t t p s : / / d e v e l o p e r. a m a z o n . c o m / j a / d o c s / c u s t o m - s k i l l s / s l o t - t y p e - re f e re n c e . h t m l # a m a z o n s e a rc h q u e r y “Ϣʔβʔ͕࣭໰ͦ͠͏ͳ͜ͱΛߟ͑Δͱ͖͸ɺ ඪ४·ͨ͸ΧελϜͷεϩοτλΠϓΛ࢖༻ͯ͠ ΑΓ༧ଌ͠΍͍͢ϢʔβʔೖྗΛΩϟϓνϟ͠ɺ AMAZON.SearchQueryεϩοτλΠϓΛ࢖༻ͯ͠ ݕࡧΫΤϦʔΛߏ੒͢Δɺ ΑΓ༧ଌ͠ʹ͍͘ೖྗΛΩϟϓνϟ͢Δ͜ͱΛݕ౼͍ͯͩ͘͠͞ɻ”

Slide 10

Slide 10 text

౎ ࢢ ɾ ஍ Ҭ Λ ݕ ࡧ ͢ Δ Π ϯ ςϯ τ ͷ α ϯ ϓϧ { "intents": [ { "name": "SearchIntent", "slots": [ { "name": "Query", "type": "AMAZON.SearchQuery" }, { "name": "City", "type": "AMAZON.CITY" } ], "samples": [ "࠷دΓͷ{Query}Λ୳ͯ͠", "{Query}Λݟ͚ͭͯ", "{Query}Λݕࡧͯ͠", "{City}ʹ͍ͭͯৄ͘͠ڭ͑ͯ" ] } ] }

Slide 11

Slide 11 text

A M A Z O N . S e a rc h Q u e r y ʹ པ Γ ͢ ͗ ͳ ͍ • ϏϧτΠϯεϩοτ͸ಛఆͷϫʔυͷೝࣝʹڧ͍ • SearchQuery͸දه༳Ε͕ى͖΍͍͢ • ۀքݻ༗ͷසग़༻ޠͳͲ͸ΧελϜεϩοτͰͳΔ΂͘Χόʔ • [ଟ෼]ϑΥʔϧόοΫ͘Β͍ͷؾ࣋ͪͰ࢖͏ͷ͕ྑͦ͞͏

Slide 12

Slide 12 text

A g e n d a • AlexaͰͷ୯ޠݕࡧ͸Amazon.SearchQuery • ElasticsearchͰݕࡧΛϒʔετ • SPARQL͸͍͍ͧ

Slide 13

Slide 13 text

ί ϯ ς ϯ π ͕ ಈ త ͳ ͷ Ͱ ε ϩ ο τ ࡞ Ε ͳ ͍ ໰ ୊

Slide 14

Slide 14 text

͜ ͏ ͍ ͏ ͷ ͕ ཉ ͠ ͍

Slide 15

Slide 15 text

ೖ ྗ ଆ Ͱ ೉ ͠ ͚ Ε ͹ ɺ ݕ ࡧ ଆ Ͱ ΍ Ε ͹ ͍ ͍ ͷ Ͱ ͸ ʁ

Slide 16

Slide 16 text

E l a s t i c s e a rc h h t t p s : / / w w w. e l a s t i c . c o / j p / p ro d u c t s / e l a s t i c s e a rc h

Slide 17

Slide 17 text

W h a t ’s a b o u t E l a s t i c s e a rc h ? • શจݕࡧͷͨΊͷOSS • ෳࡶͳݕࡧΫΤϦͷ࣮ߦ΋ߴ଎ͰՄೳ • AWSʹϚωʔδυαʔϏε͕͋Δ

Slide 18

Slide 18 text

A E S : A m a z o n E l a s t i c s e a rc h S e r v i c e h t t p s : / / a w s . a m a z o n . c o m / j p / e l a s t i c s e a rc h - s e r v i c e /

Slide 19

Slide 19 text

W h a t ’s a b o u t A E S ? • ϑϧϚωδʔυܕElasticsearch • IAMϩʔϧͳͲͰͷΞΫηε੍ޚ • Kibanaͷఏڙ͋ΓɾCognito User PoolsͰϩάΠϯೝূՄೳ • t2.micro.elasticsearch͕ແྉ࿮ʢ750h/monthʣ

Slide 20

Slide 20 text

A E S Λ A l e x a Ͱ ࢖ ͏

Slide 21

Slide 21 text

I A M ϙ Ϧ γ ʔ ʢ S e r v e r l e s s F W ʣ

Slide 22

Slide 22 text

n p m ϥ Π ϒ ϥ Ϧ ͷ ௥ Ճ $ npm i -S elasticsearch http-aws-es

Slide 23

Slide 23 text

C l i e n t Π ϯελ ϯε ͷ η ο τΞ ο ϓ const config = { hosts: [ ‘https://YOUR_DOMAIN.es.amazonaws.com' ], connectionClass: require('http-aws-es') } const AESClient = require(‘elasticsearch').Client(config)

Slide 24

Slide 24 text

ݕ ࡧ ͷ ࣮ ߦ const query = { index: '*', body: { query: { term: { title: 'Hello World' } } } } const body = await AESClient.search(query)

Slide 25

Slide 25 text

E l a s t i c s e a c h Ͱ Ͱ ͖ Δ ͍ Ζ Μ ͳ ݕ ࡧ

Slide 26

Slide 26 text

σ ʔ λ ͷ શ औ ಘ const query = { index: '*', body: { } }

Slide 27

Slide 27 text

t i t l e ʹ ର ͢ Δ ׬ શ Ұ க const query = { index: '*', body: { query: { term: { title: 'Hello World' } } } }

Slide 28

Slide 28 text

t i t l e ʹ ର ͢ Δ A N D ݕ ࡧ const query = { index: '*', body: { query: { match: { title: 'Hello World' } } } }

Slide 29

Slide 29 text

t i t l e / c o n t e n t ʹ ର ͢ Δ A N D ݕ ࡧ const query = { index: '*', body: { query: { multi_match: { "fields": [ "title", "content"], "query": "WordCamp Tokyo", “operator": "and" } } } }

Slide 30

Slide 30 text

t i t l e / c o n t e n t ʹ ର ͢ Δ ͋ ͍ · ͍ ݕ ࡧ const query = { index: '*', body: { query: { fuzzy_like_this: { fields: [“title”, “content”], like_text: 'Hello World' } } } } H e l l o w o r l d ʹ ྨ ࣅ ͢ Δ ί ϯ ςϯ π ΋ ฦ ͢

Slide 31

Slide 31 text

Ϩε ϙ ϯε ͷ ` _ s c o re ` Ͱ ྨ ࣅ ੑ Λ ൑ ఆ "hits": { "total": 207, "max_score": 3.0256464, "hits": [ { "_index": "bank", "_type": "account", "_id": "590", "_score": 3.0256464,

Slide 32

Slide 32 text

ͦ ͷ ଞ Ͱ ͖ Δ ࣄ • KibanaͰͷίϯςϯπϏδϡΞϥΠζɾ෼ੳ • more_like_thisΫΤϦͰͷྨࣅίϯςϯπݕࡧ • ೔࣌ͷൣғݕࡧ΍Ң౓ܦ౓͔Βͷपล৘ใݕࡧ • Elastic StackͳΒػցֶशతͳ͜ͱ΋Մೳ(Not AWS)

Slide 33

Slide 33 text

A g e n d a • AlexaͰͷ୯ޠݕࡧ͸Amazon.SearchQuery • ElasticsearchͰݕࡧΛϒʔετ • SPARQL͸͍͍ͧ

Slide 34

Slide 34 text

͜ ͜ · Ͱ ͷ ࿩ ί ϯ ς ϯ π Λ ࣗ ෼ Ͱ ؅ ཧ

Slide 35

Slide 35 text

࣍ ͷ ࿩ ࠓ ͋ Δ ί ϯ ς ϯ π Λ ׆ ༻ ͢ Δ

Slide 36

Slide 36 text

D B P e d i a - W i k i p e d i a Λ L O D Խ ͢ Δ P J h t t p : / / j a . d b p e d i a . o rg /

Slide 37

Slide 37 text

W h a t ’s a b o u t L O D • Liked Open Data • σʔλಉ࢜ΛϦϯΫͤ͞ΔͨΊͷٕज़ • શͯͷσʔλ͕URIΛ΋ͪɺHTTP(s)ͰΞΫηεͰ͖Δ • RDFͳͲͰσʔλ͕ߏ଄Խ͞Ε͍ͯΔ

Slide 38

Slide 38 text

W h a t ’s a b o u t R D F • Resource Description Framework • Ϧιʔεʢσʔλʣͷߏ଄ɾؔ܎৘ใΛఆٛ͢Δ • KVS΍ςʔϒϧͰ͸ͳ͘ɺʮओޠɾड़ޠɾ໨తޠʯͰσʔλΛఆٛ

Slide 39

Slide 39 text

W h a t ’s a b o u t R D F • ৘ใɿۭͷ৭͸੨͍ • RDF: ʮhttps://example.com/ۭ https://example.com/৭ https:// example.com/੨ʯ • औಘͨ͠URL͔Βʮۭɾ৭ɾ੨ʯͷؔ࿈৘ใΛ͞ΒʹҾ͚Δ • -> σʔλಉ͕࢜URLͰϦϯΫ͍ͯ͠ΔɿLinked Open Data

Slide 40

Slide 40 text

W h a t ’s a b o u t S PA R Q L • RDFͷݕࡧʹ࢖͏ΫΤϦݴޠ • SQLʹΑ͘ࣅ͍ͯΔ͕ɺWHERE͕۟SVO(ओޠड़ޠ໨తޠ)ܗࣜ • Ϛονํ๏͸WHEREͰͷ׬શҰக͔FILTERͰͷਖ਼نදݱ͘Β͍ • දه༳Ε͕ෆ҆ͳ৔߹͸ElasticsearchͳͲ΁ΠϯσοΫεͯ͠࢖͓͏

Slide 41

Slide 41 text

஀ ੜ ೔ ͕ 1 ݄ 1 ೔ SELECT DISTINCT ?s ?label ?birthYear WHERE { ?s 1 ; 1 ; ?birthYear ; rdfs:label ?label . } ORDER BY ?birthYear

Slide 42

Slide 42 text

࣮ ߦ ݁ Ռ https://bit.ly/2OK8E31

Slide 43

Slide 43 text

D B P e d i a x A l e x a Λ ΍ ͬͯ Έ ͨ h t t p s : / / w w w. a m a z o n . c o . j p / H i d e t a k a - O k a m o t o - ͝ ౰ ஍ Ϛ ε ί ο τΨ Π υ / d p / B 0 7 J L P Q N 4 M /

Slide 44

Slide 44 text

O p e n D a t a Λ ࢖ ͬ ͨ εΩϧ ։ ൃ ͷ ஫ ҙ ఺ • ϥΠηϯεදه͸εΩϧৄࡉͱϔϧϓɾDisplayɾΧʔυʹ͍ΕΑ͏ • σʔλͷߏ଄͕ἧ͍ͬͯͳ͍͜ͱ͕͋ΔͷͰཁ஫ҙ • Wikipediaʹ͋Δ৘ใ͕͢΂ͯ͋ΔΘ͚Ͱ͸ͳ͍ • σʔλ͕ॻ͖ݴ༿ͳͷͰɺม׵ඞਢ • ਖ਼نදݱ͔SELECT͔͠ͳ͍ͷͰɺSearchQueryʹཔΓ͗͢ͳ͍ʂ

Slide 45

Slide 45 text

D i s p l a y ޲ ͚ ͷ ද ࣔ ྫ

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

n p m i - S @ h i d e o k a m o t o / s i m p l e - s p a rq l - c l i e n t h t t p s : / / h i d e o k a m o t o . g i t h u b . i o / s p a rq l - c l i e n t /

Slide 48

Slide 48 text

ॻ ͖ ݴ ༿ Λ ࿩ ͠ ݴ ༿ ʹ ม ͑Δ ΍ ͭ h t t p s : / / a s k - u t i l s . g i t h u b . i o / a s k - j p - f o r m a t t e r /

Slide 49

Slide 49 text

· ͱ Ί • ϏϧτΠϯɾΧελϜεϩοτ+SearchQueryͰݕࡧڧԽ • Elasticsearch / SPARQLͳͲͰΑΓڧྗͳݕࡧ͕࣮ݱՄೳ • ࣭໰ʹ౴͑ΔͨΊʹݕࡧΛ࢖͏ݕࡧεΩϧ • ಉ͡ΫΤϦͰ౴͑Λऔಘ͠ɺͦΕΛ໰୊ʹ͢Ε͹ΫΠζεΩϧʹ • ΈΜͳ͍ΖΜͳσʔλͰϚογϡΞοϓ͠Α͏ʂ

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

h t t p s : / / b i t . l y / 2 B 4 B p n D