Slide 1

Slide 1 text

॓ധ༧໿αΠτʹ͓͚Δ ݕࡧͱྉۚܭࢉͷཱ྆ Shoichi Kaji

Slide 2

Slide 2 text

॓ധ༧໿αΠτ Ұٳ.com

Slide 3

Slide 3 text

࿩͢͜ͱ • ॓ധ༧໿αΠτҰٳ.comͰ͸ͨ͘͞Μͷ৔ॴͰ "ྉۚ"Λܭࢉ͠ද͍ࣔͯ͠Δ • ݕࡧͱྉۚܭࢉ͸ີ઀ʹؔ࿈͍ͯ͠Δ • Solr + Solr pluginͰݕࡧͱྉۚܭࢉΛཱ྆ͤ͞ ͍ͯΔ

Slide 4

Slide 4 text

Ұٳ.comʹ͓͚Δྉۚͷදࣔ ͨ͘͞Μͷ৔ॴͰ"ྉۚ"Λ ද͍ࣔͯ͠Δ "ྉۚ"͸Ϣʔβ͕ϗςϧΛ બͿ্Ͱॏཁͳࢦඪͷͻͱͭ

Slide 5

Slide 5 text

"ྉۚ"ʹٻΊΒΕΔ΋ͷ • ֤छ৚݅ɺ֤छׂҾΛՃຯ্ͨ͠Ͱͷྉۚ -> ࣄલʹ͢΂ͯͷ৔߹ΛٻΊ͓ͯ͘ͷ͸ࠔ೉ɺ ΦϯϥΠϯͰܭࢉ͢Δඞཁ͕͋Δ • ࢠڙྉۚ • ׂҾͷ৚݅: ର৅ձһϥϯΫɺ༗ޮظݶɺର৅॓ധ೔ɺഉଞ੍ޚ • ຊདྷྉۚ͸༧໿ʹରܾͯ͠·Δ΋ͷ • τοϓϖʔδʹ͸֤ϗςϧʹྉ͕ۚදࣔ͞Ε͍ͯΔɻ͜Ε͸͜ͷϗςϧ͕औΓ͏Δྉۚ ͷதͰͷ࠷খ஋Λද͍ࣔͯ͠Δ (collapse)ɻΑͬͯཪͰ͸Կेഒ΋ͷྔͷྉۚܭࢉΛ͠ ͳ͍ͱ͍͚ͳ͍ • ݕࡧϖʔδʹදࣔ͞Ε͍ͯΔྉۚ͸ɺ֤छ fi lterΛ൓өͨ͠΋ͷ • ͨͱ͑͹ʮே৯෇͖ʯͱ͍͏ fi lter͕՝͞ΕΕ͹ɺே৯෇͖ϓϥϯͷྉۚͷ࠷҆஋

Slide 6

Slide 6 text

ݕࡧͱྉۚܭࢉ͸ີ઀ʹؔ࿈ • લड़ͷ௨ΓɺྉۚܭࢉͷதͰcollapse, fi lterͳͲ "ݕࡧ"จ຺Ͱग़ͯ͘Δͷͱಉ͡ॲཧΛඞཁͱ͢Δ • ܭࢉ͞ΕͨྉۚΛʮ2ສԁҎԼͷϗςϧʹߜΔʯ ʮྉۚͷ͍҆ॱʹฒ΂ΔʯͳͲݕࡧͷ fi lter, sort ʹ࢖͏͜ͱ΋͋Δ • ݕࡧͱྉۚܭࢉ͸ಉ࣌ʹѻ͑ͳ͍ͱ͍͚ͳ͍

Slide 7

Slide 7 text

໰୊ ີ઀ʹؔ࿈͠߹ͬͨݕࡧɺ ྉۚܭࢉΛͲ͏࣮ݱ͢Δ͔ʁ

Slide 8

Slide 8 text

ݕࡧ • ·ͣ͸ݕࡧ • ҰൠʹݕࡧΤϯδϯͱͯ͠Elasticsearch, Apache SolrͳͲ͕ީิͱ͕ͯ͋͠Δ • Ұٳ.comͰ͸Apache SolrΛ࠾༻͍ͯ͠Δ

Slide 9

Slide 9 text

ݕࡧ Solr • Apache Solr • "ݕࡧ"ͱݴͬͯࢥ͍ු͔Ϳػೳ͸͍͍ͩͨἧ͓ͬͯΓɺ ͱͯ΋Α͍ιϑτ΢ΣΞͩͱࢥ͏ https://solr.apache.org/

Slide 10

Slide 10 text

ྉۚܭࢉ • ࣍ʹྉۚܭࢉɻલड़ͷ௨Γɺྉۚܭࢉ͸ݕࡧͱಉ࣌ʹͰ͖Δ ͷ͕๬·͍͠ɻSolrͰྉۚܭࢉ͸Ͱ͖Δʁ • SolrͰ͸query্ͰࣜΛఆٛ͠ɺͦͷ݁ՌΛฦ͢͜ͱ͸Ͱ͖Δ • ྉۚܭࢉ΋Solr query্ͰࣜΛఆٛ͢Ε͹͍͍ͷͰ͸ʁ // query.json { "query": "*:*", "fields": [ "product(sum(Price1_i,Price2_i),div(sub(100,Rate_f),100))" ] } // response { "response":{"docs":[{ "product(sum(Price1_i,Price2_i)...)":50487.36 }]} }

Slide 11

Slide 11 text

ྉۚܭࢉ • ྉۚܭࢉ΋Solr query্ͰࣜΛఆٛ͢Ε͹͍͍ͷͰ͸ʁ • ౴͑: ݫ͍͠ 🥲 • ෳࡶͳܭࢉΛSolr query্Ͱදݱ͢Δͷ͸͔ͳΓݫ͠ ͍ɻͱ͘ʹҰ࣌ม਺Λѻ͍ʹ͍͘ • ܭࢉ͕ෳࡶͩͱͦͷ෼Solr queryͷαΠζ΋૿͑Δɻ ͦͯ͠parseͷίετ΋͔ͳΓ͔͔Δ

Slide 12

Slide 12 text

ྉۚܭࢉ Solr plugin • Ͱ͸Ͳ͏͢Δ͔ʁ • Solrʹ͸pluginػߏ͕͋Δ • JavaͰϓϩάϥϜΛॻ͖ɺSolrͷ֤छॲཧΛ ΧελϚΠζͰ͖Δ • ಛʹSolr query্Ͱ࢖͑Δಠࣗؔ਺ΛఆٛͰ͖Δ

Slide 13

Slide 13 text

ྉۚܭࢉ Solr plugin • Solr query্ͰྉۚΛܭࢉͯ͠ฦ͢ my_priceؔ਺Λಋೖ͠ɺͦͷ࣮૷Λ MyPriceParser.javaͱͯ͠ॻ͚͹Α͍ // my_priceͷ࣮૷: MyPriceParser.java public class MyPriceParser extends ValueSourceParser { @Override public ValueSource parse(FunctionQParser fp) throws SyntaxError { ... } } // query.json { "query": "*:*", "fields": [ "my_price(20240901,2,3)" ] }

Slide 14

Slide 14 text

ྉۚܭࢉ Solr plugin • Solr pluginʹΑΔಠࣗؔ਺࣮૷͸ଟ͘ͷར఺͕͋Δ • JavaͰهड़Ͱ͖ΔͷͰɺม਺ɺΫϥεͳͲͳΜͰ΋࢖͑Δ • indexσʔλͷಡΈऔΓ΋JavaͰهड़Ͱ͖ΔͷͰɺಠࣗʹγϦΞϥΠζͨ͠ σʔλͳͲΛindex͠࢖͏͜ͱ΋Ͱ͖Δ • σʔλιʔεͱͯ͠indexσʔλҎ֎ͷ΋ͷ΋࢖͑Δ • ͦͯ͠΋ͪΖΜmy_priceΛ fi lter,sortͯ͠΋࢖͑Δʂ • { "query": "*:*", "filter": ["{!frange u=20000}my_price(20240901,2,3)"], // 2ສԁҎԼ "sort": "my_price(20240901,2,3) asc", // ྉۚͷ͍҆ॱ "fields": ["my_price(20240901,2,3)"] }

Slide 15

Slide 15 text

Solr + Solr pluginΛ࢖ͬͯ ݕࡧɺྉۚܭࢉΛཱ྆Ͱ͖ͨ 😉

Slide 16

Slide 16 text

·ͱΊ • ॓ധ༧໿αΠτҰٳ.comͰ͸ͨ͘͞Μͷ৔ॴͰ "ྉۚ"Λܭࢉ͠ද͍ࣔͯ͠Δ • ݕࡧͱྉۚܭࢉ͸ີ઀ʹؔ࿈͍ͯ͠Δ • Solr + Solr pluginͰݕࡧͱྉۚܭࢉΛཱ྆ͤ͞ ͍ͯΔ