ã¯ããã«
ããã«ã¡ã¯ãã³ã³ã·ã¥ã¼ãäºæ¥é¨ããã¯ã¨ã³ãã¨ã³ã¸ãã¢ã®é«æ©ã§ãã
ä»åã¯é£äºã¡ãã¥ã¼æ¤ç´¢æ©è½ã«OpenSearchãå°å
¥ãããã¨ã«ã¤ãã¦ãã話ãããã¦é ããã¨æãã¾ãã
ããããã¡ãã¥ã¼æ¤ç´¢ç»é¢
ãªãå°å ¥ãããã¨æã£ãã®ã
ãããã¤ãªã¼ã¹ã¯ã©ã ã«ã¦ããâæ°´ç¾ç¾¹ ã¨ããâãã§ã¯æ¤ç´¢ã§ããã®ã«ããâæ°´ãããã ã¨ããâ ãã§ã¯æ¤ç´¢ã§ããªããã¨ããææãã§ã¦ãã¾ããã確ãã«ããã¯ã¦ã¼ã¶ã¼ã«ã¨ã£ã¦æ¤ç´¢ã§ããªãçç±ããããããã¦ã¼ã¶ããªãã£ãä½ãã¨æãã¾ãããã¾ãã以åãããæ¢ãããé£åããªããªãæ¤ç´¢ã§ãããããªããã¨ããæ¹åè¦æãããã¾ãããããããä»åã®å°å ¥ã®ãã£ããã§ãã
以åã®ã¡ãã¥ã¼æ¤ç´¢
以åã®æ¤ç´¢ã§ã¯ãã¼ã¿ãã¼ã¹ã«å¯¾ãSQLã®é¨åä¸è´æ¤ç´¢ãè¡ã£ã¦ãã¾ããã
OpenSearchã§æ¤ç´¢ãè¡ããç¶æ
ã«ããããã«ã¯ãã¼ã¿ãã¼ã¹ããOpenSearchã¸ãã¼ã¿ãåæããå¿
è¦ããããã¾ãããããã®ãã¼ã¿ã¯å¼ç¤¾ã®æ é¤å£«ã«ãã£ã¦æ¥ã
æ¹åãè¡ããã¦ãããã¨ãèæ
®ããåææ¹æ³ãèãã¾ããã
MySQLããOpenSearchã¸ã®ãã¼ã¿ã®åææ¹æ³
å¥ã·ã¹ãã ã§æ¥ã å¼ç¤¾ã®æ é¤å£«ã«ãã£ã¦ãã¼ã¿ã®æ´æ°ã¯è¡ããããã®ã®ãããã¾ã§ã®ãªã¢ã«ã¿ã¤ã æ§ã¯æ±ãããã¦ããªããã¨ããã1æ¥1åã®åæããããå®è¡ããããã«ãã¾ããã
OpenSearchå ã®Indexæ´ãæ¿ãã¯ä¸è¨ã®ãããªã¯ã¼ã¯ããã¼ãä½æãããã¼ã¿åæç¨Aliasã«è¨å®ããIndexã«ãã¼ã¿åæããæ¤ç´¢ç¨Aliasã«è¨å®æ¸ã¿ã ã£ãå¤ãIndexã¨ãã¼ã¿åæå¾ã®Indexãå ¥ãæ¿ããå¦çãèãã¾ããããããããã¨ã§ãå ¥ãæ¿ããã®ã¯æ¬ä½ãã¼ã¿ã®ã¿ã¨ãªããæ¤ç´¢é¨åã®å¦çã«å½±é¿ãããã«èªåã§ãã¼ã¿ã®æ´æ°ãè¡ããããã«ãªãã¾ãã
失ææã®ãã¼ã«ããã¯ã«é¢ãã¦ã¯ãææ°ã®ãã¼ã¿åææåæ¥ããæ°æ¥åã®éå»ãã¼ã¿Indexãæ®ãã¦ããããã«ããææ°ã®æåæ¥ã®Indexã«åãæ¿ãããã¨ã§ã失æã®åå 究æãã復æ§ã¾ã§ã®éã極åæ¤ç´¢æ§è½ã®å£åããªãããã«ãã¾ããã
OpenSearchã«ããæ¤ç´¢æ¹åæ¹æ³
ä»åã¯ããèªç¶ã«æ¥æ¬èªã解éãããæ¹æ³ã¨ãã¦ãå½¢æ ç´ è§£æ*1ãæ¡ç¨ãã¾ããã
å½¢æ
ç´ è§£æã¨ãã¦ã¯ãkuromojiã¨sudachiã¨ãããã©ã°ã¤ã³ãæ¯è¼ããé©åç*2ãé«ãã£ãsudachiãæ¡ç¨ãã¾ããã
以åã®æ¤ç´¢ã¯é¨åä¸è´ãè¡ã£ã¦ããã®ã§ããã®æ¤ç´¢çµæãããç¨åº¦æ
ä¿ããç®çã§N-gramãæ¡ç¨ãã¾ããã
å½¢æ
ç´ è§£æã¯é©åçãé«ããªããåç¾ç*3ãä½ããªããN-gramã¯åç¾çãé«ããªããé©åçãä½ããªãã®ã§ãä¸è¬çã«ãããã¯ãã¬ã¼ããªãã®é¢ä¿ã«ããã¾ãã
å½¢æ
ç´ è§£æã¨N-gramã®ä¸¡æ¹ãIndexåããã©ã¡ãã«å¯¾ãã¦ãæ¤ç´¢ãè¡ãæ¹æ³ã§æ¹åãããã¨ã§ãé©åçã¨åç¾çãããæé
ã§ãã¥ã¼ãã³ã°ã§ããã¨æãã¾ãã
ï¼詳細はこちらを参照:全文検索を日本語向けにチューニングするï¼
ãã®ä»ã®æ¹åã¨ãã¦ã¯ãã¦ã¼ã¶ã¼ã®æ¤ç´¢ãã¼ã¯ã¼ãããã®ç»é²çãªã©ã解æããã¦ã¼ã¶ã¼è¾æ¸ã®å
容ãæ¡å
ããã¦ãããã¨ã§ãããããã¦ã¼ã¶ã¼ã«ç¹åããè¾æ¸ãä½æããæ´»åããã¾ããã
analyzerã®è¨å®ä¾
Indexæãæ¤ç´¢æãåãanalyzerã使ç¨ãããã®ã¨ãã¾ãã
ä¸è¨ã§ãè¿°ã¹ã¦ããéãä»åã¯sudachiã使ç¨ãã¦ãã¾ãã
"analysis": { "tokenizer": { "ngram_tokenizer" : { "token_chars" : [ "letter", "digit" ], "min_gram" : "1", "type" : "ngram", "max_gram" : "2" }, "sudachi_b_tokenizer": { "type": "sudachi_tokenizer", "additional_settings": "{\"systemDict\":\"system_core.dic\"}", "split_mode": "B", "discard_punctuation": true } }, "analyzer": { "b_analyzer": { "type": "custom", "filter": [ "sudachi_normalizedform", "sudachi_baseform", "sudachi_part_of_speech" ], "tokenizer": "sudachi_b_tokenizer" }, "ngram": { "type": "custom", "char_filter" : [ "icu_normalizer" ], "tokenizer": "ngram_tokenizer" } } } }
mappingã®è¨å®ä¾
Indexããããï¼ã¤ï¼ã¤ã®é ç®(titleãdescriptionç)ã«å¯¾ãã¦åå¥ã«mappingãããã¨ãã§ãã¾ãããããã ã¨å®ç¾©ããã®ã大å¤ãªã®ã§ãdynamic_templatesã使ã£ã¦Indexã®ãããã³ã°ã楽ã«è¡ããã¨ãã§ãã¾ãã
"mappings": { "dynamic_templates" : [ { "string_template" : { "match" : "*", "match_mapping_type" : "string", "mapping" : { "fields" : { "analyzed" : { "analyzer" : "b_analyzer", "type" : "text" }, "ngram" : { "analyzer" : "ngram", "type" : "text" } } } } } ] }
詳ãã説æã¯参考ããåç §ããã ãã¨ããç解ãæ·±ã¾ãã¾ãã
è¦å´ãããã¨
å¤ãã®ã¦ã¼ã¶ã¼ã«ãå©ç¨ããã ãã¦ããåã以åã®æ¤ç´¢çµæã§æ
£ãã¦ããã¦ã¼ã¶ã¼ãå¤ããæ¹åããé¨åã¨æ¢åã¨å¤ããªãé¨åãèæ
®ãããã¥ã¼ãã³ã°ãããå¿
è¦ãããã¾ããã
æçµçã«ã¯ã¦ã¼ã¶ã¼ã«ä½¿ã£ã¦ããããªããæ¹åãã¦ãããã¨ãè¯ãã¨å¤æãã段éçã«ãªãªã¼ã¹ãè¡ãå®éã«ã¦ã¼ã¶ã¼ã®é£äºã¡ãã¥ã¼ç»é²çãã¬ãã¥ã¼ãæ¥ã
確èªãã¦ãããã¨ã§ãã¦ã¼ã¶ã¼ã«å½±é¿ãåºã¦ããªããå¹ççã«å¤æããªããä½æ¥ãè¡ããã¨ãã§ãã¾ããã
å°å ¥ããçµæ
æ¹åçµæã®ææ¨ã¨ãã¦ã¦ã¼ã¶ã¼ã®é£äºã¡ãã¥ã¼ç»é²çãæ¹ååã¨æ¹åå¾ã§æ¯è¼ããã¨ãããå¤åãªãã¨ããçµæã«ãªãã¾ããã
ç»é²çã«å½±é¿ããã»ã©ã®çµæã¯ä»ã®ã¨ãã確èªã§ãã¦ãã¾ããããä»å¾ã®æ´»å次第ã§ã¾ã ã¾ã åä¸ã§ããå¯è½æ§ãããã¾ãã®ã§ããããããåãçµãã§ããããã¨æãã¾ãã
ã¡ãªã¿ã«ãæ°´ãããã ã¨ãããã¯æ¤ç´¢ã§ããããã«ãªãã¾ããã
ã¾ã¨ã
ä»åã¯ããããã®ã¡ãã¥ã¼æ¤ç´¢ã«OpenSearchãå°å
¥ãã¦ã¿ã¾ããã
ããããããã精度ãä¸ãã¦ããããã«AIã®å°å
¥ãªã©å¸¸ã«æåã®æ¹åãã§ããããåãçµãã§åãããã¨æã£ã¦ããã¾ãã
ããã誰ãã®åèã«ãªãã°å¹¸ãã§ãã
askenã§ã¯åµæ工夫ãã¦æ¥åãéè¡ã§ããã¨ã³ã¸ãã¢ãå¹
åºãåéãã¦ãã¾ãã
èå³ãæã£ã¦ããã ããæ¹ã¯ã«ã¸ã¥ã¢ã«é¢è«ããã¾ãã¯ã話ããã¾ããã§ããããï¼ï¼
ãæ°è»½ã«ãé£çµ¡ãã ããã
www.asken.inc
åè
*1:å½¢æ ç´ è§£æã¨ã¯ãè¨èªã«ããã¦æå³ãæã¤æå°ã®åä½(ï¼å½¢æ ç´ )ã«ç´°ååããï¼ã¤ï¼ã¤ã®åè©ã»å¤åãªã©ãå¤å¥ãã¦ããä½æ¥
*2:é©åçï¼precisionï¼ï¼ã©ãã ãæ¤ç´¢ãã¤ãºãå°ãªãã
*3:åç¾çï¼recallï¼ï¼ã©ãã ãæ¤ç´¢æ¼ããå°ãªãã