Re: ACFinder テスト中
OhYeah!
投稿数: 983
オンライン

病害虫ダイアログボックスの検索ですが、concat('、',byochu,betsumei) から検索する場合、前方一致・後方一致は MATCH だと別名がうまく検索できません。REGEXP の方が良さそうです。
引用:ただし従来のように1行まるごとinsert ではなく、フィールドを選択する処理を加えているので、遅くなっていると思います。薬検 CSV も MACS CSV も項目数・項目順ともに同じですが、どうして別処理が必要になったんでしょうか?
登録基本部は、テンポラリテーブルを作成してから seibun と m_kihon に分けてたと思いましたが、これを Delphi 側でテーブル作成時に処理するようにしたとか?
引用:「なばな類」だけを明示的に指定した場合に、「なばな」がヒットするのもまずいかも。ああ、なるほどそういうケースもありますね。検索方法をまるっきり変えてしまうのは面倒でしょうか?
ACFinder の検索方法では、たとえば「ねぎ」を選択した場合に「根深ねぎ」で登録されている農薬が検索できないため、携帯農薬検索では下記のような検索方法をとっています。この場合、展着剤など大分類が異なる農薬は検索できませんが、薬剤名等からの検索や病害虫名等からの検索で検索できれば OK かなと割り切っています。ACFinder の検索方法でも、「ねぎ」を選んだんじゃ「ヨトウコン-S」などは検索できないですしね。
0: idsaku regexp '^(xx000000)'
1: idsaku regexp '^(xx000000|xxxx0000)'
2: idsaku regexp '^(xx000000|xxxx0000|xxxxx000)'
3: idsaku regexp '^(xx000000|xxxx0000|xxxxx000|xxxxxxxx)'
4: idsaku regexp '^(xx000000|xxxx0000|xxxxx000|xxxxxxxx00|xxxxxxxxxx)'
たとえば、「ねぎ」(level = 3, idsaku = 0205003100)の場合、最終的な SQL は下記のようになります。
SELECT byochu FROM m_byochu WHERE concat('、',byochu,betsumei) REGEXP '(^|、)検索語'
SELECT byochu FROM m_byochu WHERE concat('、',byochu,betsumei) REGEXP '検索語(\(|、|$)'
引用:ただし従来のように1行まるごとinsert ではなく、フィールドを選択する処理を加えているので、遅くなっていると思います。薬検 CSV も MACS CSV も項目数・項目順ともに同じですが、どうして別処理が必要になったんでしょうか?
登録基本部は、テンポラリテーブルを作成してから seibun と m_kihon に分けてたと思いましたが、これを Delphi 側でテーブル作成時に処理するようにしたとか?
引用:「なばな類」だけを明示的に指定した場合に、「なばな」がヒットするのもまずいかも。ああ、なるほどそういうケースもありますね。検索方法をまるっきり変えてしまうのは面倒でしょうか?
ACFinder の検索方法では、たとえば「ねぎ」を選択した場合に「根深ねぎ」で登録されている農薬が検索できないため、携帯農薬検索では下記のような検索方法をとっています。この場合、展着剤など大分類が異なる農薬は検索できませんが、薬剤名等からの検索や病害虫名等からの検索で検索できれば OK かなと割り切っています。ACFinder の検索方法でも、「ねぎ」を選んだんじゃ「ヨトウコン-S」などは検索できないですしね。
// ACFinder の concat スカラー関数と同じ動作の PHP ユーザ関数
function _concat() {
if (func_num_args() < 2) return '';
$args = func_get_args();
$connector = array_shift($args);
$res = array_shift($args);
foreach($args as $arg) {
if (is_null($arg) || $arg == '') continue;
if (strpos($res, $arg) === false) $res .= $connector.$arg;
}
return $res;
}
$crop = 選択作物名;
$cid = 選択作物名の idsaku;
$level = 選択作物名の level;
$cid2 = substr($cid, 0, 8);
$except = _concat('|', substr($cid, 0, 4)."000000", substr($cid, 0, 5)."00000", "{$cid2}00"); // substr は PHP の substr 関数
$sql = "select concat('|', sakumotsu) from sakumotsu where idsaku regexp '$except'";
$except = 上記$sqlの実行結果;
$except = '\((.*、)?('.str_replace(array('(', ')', '[', ']'), array('\(?', '\)?', '\[?', '\]?'), $except).')(、.*)?を除く';
if (strpos($crop, '露地') !== false) $except .= '|施設|水耕';
if (strpos($crop, '施設') !== false) $except .= '|露地';
if (strpos($crop, '水耕') !== false) $except .= '|露地';
$cond = _concat('|', substr($cid, 0, 2)."000000", substr($cid, 0, 4)."0000", substr($cid, 0, 5)."000"); // substr は PHP の substr 関数
if ($level == 3) $cond = _concat('|', $cond, "{$cid2}");
if ($level == 4) $cond = _concat('|', $cond, "{$cid2}00", $cid);
$sql = "select sakumotsu from m_sakumotsu where idsaku regexp '^($cond)' and sakumotsu not regexp '$except'";
選択作物の level により、下記のように作物を検索します。level = 0..2 の場合は、指定作物と上位分類のみで、下位分類は検索しません。level = 3 の場合は、上位分類と下位分類を全て検索します。level = 4 の場合は、もともと下位分類が存在しないので指定作物と上位分類を検索します。0: idsaku regexp '^(xx000000)'
1: idsaku regexp '^(xx000000|xxxx0000)'
2: idsaku regexp '^(xx000000|xxxx0000|xxxxx000)'
3: idsaku regexp '^(xx000000|xxxx0000|xxxxx000|xxxxxxxx)'
4: idsaku regexp '^(xx000000|xxxx0000|xxxxx000|xxxxxxxx00|xxxxxxxxxx)'
たとえば、「ねぎ」(level = 3, idsaku = 0205003100)の場合、最終的な SQL は下記のようになります。
select sakumotsu from m_sakumotsu where idsaku regexp '^(02000000|02050000|02050031)' and sakumotsu not regexp '\((.*、)?(その他野菜|ねぎ)(、.*)?を除く'
投票数:5
平均点:6.00
投稿ツリー
-
ACFinder テスト中 (kabe, 2011.01.03 22:01)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.04 01:21)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.04 02:18)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.04 13:11)
-
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.04 10:18)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.04 15:15)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.04 18:12)
-
Re: ACFinder テスト中 (kabe, 2011.01.04 20:34)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.04 22:38)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.05 17:48)
-
-
-
Re: ACFinder テスト中 (kabe, 2011.01.04 23:09)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.05 02:16)
-
Re: ACFinder テスト中 (kabe, 2011.01.05 07:15)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.05 17:22)
-
-
-
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.06 21:42)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.07 14:35)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.09 03:29)
-
Re: ACFinder テスト中 (kabe, 2011.01.09 10:53)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.09 14:38)
-
-
Re: ACFinder テスト中 (kabe, 2011.01.09 14:04)
-
Re: ACFinder テスト中 (kabe, 2011.01.09 14:14)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.09 14:54)
-
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.09 17:08)
-
Re: ACFinder テスト中 (kabe, 2011.01.09 22:22)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.09 23:54)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.10 02:07)
-
Re: ACFinder テスト中 (kabe, 2011.01.10 21:06)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.10 21:36)
-
/u オプションは大丈夫? (OhYeah!, 2011.01.22 23:37)
-
Re: /u オプションは大丈夫? (kabe, 2011.01.23 20:24)
-
Re: /u オプションは大丈夫? (OhYeah!, 2011.01.23 22:49)
-
-
-
-
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.10 00:51)
-
Re: ACFinder テスト中 (OhYeah!, 2011.01.10 02:05)
-
-
-
-
-
検索結果の作物名・病害虫の並べ替え (OhYeah!, 2011.02.10 16:30)
-
Re: 検索結果の作物名・病害虫の並べ替え (kabe, 2011.02.11 20:59)
-
Re: 検索結果の作物名・病害虫の並べ替え (OhYeah!, 2011.02.11 22:24)
-
-
-