Upgrade to Pro — share decks privately, control downloads, hide ads and more …

宿泊予約サイトにおける検索と料金計算の両立

Shoichi Kaji
September 18, 2024

 宿泊予約サイトにおける検索と料金計算の両立

一休×AEON 事業会社のサービスを支える基盤開発トーク 2024/09/18
https://ikyu.connpass.com/event/327095/

Shoichi Kaji

September 18, 2024
Tweet

More Decks by Shoichi Kaji

Other Decks in Programming

Transcript

  1. "ྉۚ"ʹٻΊΒΕΔ΋ͷ • ֤छ৚݅ɺ֤छׂҾΛՃຯ্ͨ͠Ͱͷྉۚ -> ࣄલʹ͢΂ͯͷ৔߹ΛٻΊ͓ͯ͘ͷ͸ࠔ೉ɺ ΦϯϥΠϯͰܭࢉ͢Δඞཁ͕͋Δ • ࢠڙྉۚ • ׂҾͷ৚݅:

    ର৅ձһϥϯΫɺ༗ޮظݶɺର৅॓ധ೔ɺഉଞ੍ޚ • ຊདྷྉۚ͸༧໿ʹରܾͯ͠·Δ΋ͷ • τοϓϖʔδʹ͸֤ϗςϧʹྉ͕ۚදࣔ͞Ε͍ͯΔɻ͜Ε͸͜ͷϗςϧ͕औΓ͏Δྉۚ ͷதͰͷ࠷খ஋Λද͍ࣔͯ͠Δ (collapse)ɻΑͬͯཪͰ͸Կेഒ΋ͷྔͷྉۚܭࢉΛ͠ ͳ͍ͱ͍͚ͳ͍ • ݕࡧϖʔδʹදࣔ͞Ε͍ͯΔྉۚ͸ɺ֤छ fi lterΛ൓өͨ͠΋ͷ • ͨͱ͑͹ʮே৯෇͖ʯͱ͍͏ fi lter͕՝͞ΕΕ͹ɺே৯෇͖ϓϥϯͷྉۚͷ࠷҆஋
  2. ྉۚܭࢉ • ࣍ʹྉۚܭࢉɻલड़ͷ௨Γɺྉۚܭࢉ͸ݕࡧͱಉ࣌ʹͰ͖Δ ͷ͕๬·͍͠ɻ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 }]} }
  3. ྉۚܭࢉ • ྉۚܭࢉ΋Solr query্ͰࣜΛఆٛ͢Ε͹͍͍ͷͰ͸ʁ • ౴͑: ݫ͍͠ 🥲 • ෳࡶͳܭࢉΛSolr

    query্Ͱදݱ͢Δͷ͸͔ͳΓݫ͠ ͍ɻͱ͘ʹҰ࣌ม਺Λѻ͍ʹ͍͘ • ܭࢉ͕ෳࡶͩͱͦͷ෼Solr queryͷαΠζ΋૿͑Δɻ ͦͯ͠parseͷίετ΋͔ͳΓ͔͔Δ
  4. ྉۚܭࢉ 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)" ] }
  5. ྉۚܭࢉ 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)"] }