<html><body><div style="color:; background-color:; font-family:MS PGothic, sans-serif;font-size:12pt"><div><span>お返事、ありがとうございます。</span></div><div><span><br></span></div><div><span>></span><span style="font-size: 12pt;">(前のバージョンでできていたというのはちょっとよくわからないのですが。。。)</span></div><div><span style="font-size: 12pt;">@@オペレーター使って、以前は検索出来ていたということです。</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">か、</span></div><div><span style="font-size: 12pt;">今日また</span><span style="font-size: 12pt;">@@オペレーター使ってみたら、正常に検索出来ています。</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">で、なんで&@~オペレーターを使ったのか:</span></div><div><span
style="font-size: 12pt;">どこかで、「</span><span style="color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">この演算子=@@のこと=は1.2.0から非推奨です。代わりに</span><a href="https://pgroonga.github.io/ja/reference/operators/query-v2.html" style="box-sizing: border-box; color: rgb(51, 122, 183); text-decoration-line: none; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;"><code class="highlighter-rouge" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12.6px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">&@~</code>演算子</a><span style="color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size:
14px;">を使ってください。」と書いていたので。</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">今日、</span><span style="font-size: 12pt;">@@オペレーターで正常に検索出来たのはbackward compatibilityのおかげでしょうか。</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">項目1 or 項目2検索で、</span><span style="font-size: 12pt;">いつかは「</span><span style="font-size: 12pt;">&@~」オペレーターしか使えないのなら、今からでもそのオペレーターを使った方が良いでしょうと思って、試したのです。</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size:
12pt;">今日は、phpPgAdminコンソールのsql実行するところで、直接sql実行したました。</span></div><div>林さんが書いてくださったサンプルのsql文ですが、bindValueなしで、</div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">SELECT * FROM memos WHERE target_col &@~ <span style="font-size: 12pt;">'東京 OR 大阪';</span><br></span></div><div><span style="font-size: 12pt;"><br></span></div><div>↑を実行しました。</div><div><br></div><div>結果は前回と同じエラーです。</div><div><br></div><div>エラー:</div><div><br></div><div><pre class="error" style="font-family: "Lucida Console", "Courier New", "DejaVu Sans Mono", monospace;"><pre class="error" style="font-family: "Lucida Console", "Courier New", "DejaVu Sans Mono", monospace;">ERROR: operator does not exist: text
&@~ unknown
LINE 1: SELECT * FROM memos WHERE target_col &@~ '東京 OR 大阪'...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.</pre></pre><pre class="error" style="font-family: "Lucida Console", "Courier New", "DejaVu Sans Mono", monospace;"><br></pre><pre class="error" style="font-family: "Lucida Console", "Courier New", "DejaVu Sans Mono", monospace;"><br></pre></div><div><br></div><div><br></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;"> <div style="font-family: MS PGothic, sans-serif; font-size: 12pt;"> <div style="font-family: MS PGothic, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> ----- Original Message -----<br> <b><span style="font-weight:bold;">From:</span></b> Kentaro Hayashi <hayas****@clear*****><br>
<b><span style="font-weight: bold;">To:</span></b> groon****@lists***** <br> <b><span style="font-weight: bold;">Date:</span></b> 2017/8/2, Wed 11:40<br> <b><span style="font-weight: bold;">Subject:</span></b> [groonga-dev,04424] Re: &@~オペレーターのUndefined function: 7 ERROR: operator does not exist:エラー<br> </font> </div> <br>林です。<br><br>On Mon, 31 Jul 2017 19:39:15 +0900 (JST)<br><a ymailto="mailto:s400t****@yahoo*****" href="mailto:s400t****@yahoo*****" target="_self">s400t****@yahoo*****</a> wrote:<br><br>> MLみなさん<br>> こんにちは。<br>> <br>> 1っか月+にまたpgroonga試して見ました。<br>> 二つ単語検索のOR条件に&@~オペレーター使おうとしていますが、エラーになります。<br>> <br><br><br>>
例) target_col列の'東京'又は'大阪'をヒットさせて、一覧取得しようとしています。<br>> <br>> <a href="https://pgroonga.github.io/reference/operators/query-v2.html%E3%81%AE%E3%80%8COperator" target="_blank">https://pgroonga.github.io/reference/operators/query-v2.htmlの「Operator</a> classes」のところ:<br>> <br>> You need to specify one of the following operator classes to use this operator:と書いていますが、Usageのところにどうやってspecifyするのか、例がないのでこの以降どうすればよいのか、わかりません。前のバージョン(@@オペレーター)の時は検索出来ていました。<br>> <br>> 上記の例で、target_colの型は「text」で、そのフィールドのindexを作っています。<br>> (CREATE INDEX target_col _index ON db名 USING pgroonga (target_col );)<br><br>ということであれば、target_col &@~
"東京 OR 大阪" を指定してください。<br>(前のバージョンでできていたというのはちょっとよくわからないのですが。。。)<br><br>> 実行したSQL:<br>> $stmt = $pdo->prepare("SELECT 項目1、... FROM db名 WHERE target_col &@~ :keyword1 OR :keyword2");<br>> <br>> $stmt->bindValue(':keyword1', '東京');<br>> <br>> $stmt->bindValue(':keyword2', '大阪');<br>> <br>> $stmt->execute();<br><br>なので、上記の箇所も"東京 OR 大阪"となるように以下のようにするとよいはずです。<br><br>$stmt = $dbh->prepare("SELECT target_col FROM memos WHERE target_col &@~ :keyword");<br>$stmt->bindValue(':keyword', '東京 OR 大阪');<br>$stmt->execute();<br><br>サンプルとしては↓な感じでしょうか。<br><br> <?php<br><br> $dsn = 'pgsql:dbname=pgroonga_test host=localhost port=5432';<br> $user =
'postgres';<br> $password = 'postgres';<br><br> try{<br> $dbh = new PDO($dsn, $user, $password);<br><br> $stmt = $dbh->prepare("SELECT target_col FROM memos WHERE target_col &@~ :keyword");<br> $stmt->bindValue(':keyword', '東京 OR 大阪');<br> $stmt->execute();<br> while ($row = $stmt->fetch()) {<br> var_dump($row);<br> }<br> } catch (PDOException $e) {<br> print('Error:'.$e->getMessage());<br> die();<br> }<br> ?><br><br><br>-- <br>Kentaro Hayashi <<a ymailto="mailto:hayas****@clear*****" href="mailto:hayas****@clear*****" target="_self">hayas****@clear*****</a>><br><br>_______________________________________________<br>groonga-dev mailing list<br><a ymailto="mailto:groon****@lists*****" href="mailto:groon****@lists*****"
target="_self">groon****@lists*****</a><br><a href="http://lists.osdn.me/mailman/listinfo/groonga-dev" target="_blank">http://lists.osdn.me/mailman/listinfo/groonga-dev</a><br><br><br> </div> </div> </blockquote></div> </div></body></html>