<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>&gt;</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;">で、なんで&amp;@~オペレーターを使ったのか:</span></div><div><span
 style="font-size: 12pt;">どこかで、「</span><span style="color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, 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: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px;"><code class="highlighter-rouge" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 12.6px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">&amp;@~</code>演算子</a><span style="color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, 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;">&amp;@~」オペレーターしか使えないのなら、今からでもそのオペレーターを使った方が良いでしょうと思って、試したのです。</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 &amp;@~&nbsp;<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: &quot;Lucida Console&quot;, &quot;Courier New&quot;, &quot;DejaVu Sans Mono&quot;, monospace;"><pre class="error" style="font-family: &quot;Lucida Console&quot;, &quot;Courier New&quot;, &quot;DejaVu Sans Mono&quot;, monospace;">ERROR:  operator does not exist: text
 &amp;@~ unknown
LINE 1: SELECT * FROM memos  WHERE target_col &amp;@~ '東京 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: &quot;Lucida Console&quot;, &quot;Courier New&quot;, &quot;DejaVu Sans Mono&quot;, monospace;"><br></pre><pre class="error" style="font-family: &quot;Lucida Console&quot;, &quot;Courier New&quot;, &quot;DejaVu Sans Mono&quot;, 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 &lt;hayas****@clear*****&gt;<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: &amp;@~オペレーターの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>&gt; MLみなさん<br>&gt; こんにちは。<br>&gt; <br>&gt; 1っか月+にまたpgroonga試して見ました。<br>&gt; 二つ単語検索のOR条件に&amp;@~オペレーター使おうとしていますが、エラーになります。<br>&gt; <br><br><br>&gt;
 例) target_col列の'東京'又は'大阪'をヒットさせて、一覧取得しようとしています。<br>&gt; <br>&gt; <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>&gt; <br>&gt; You need to specify one of the following operator classes to use this operator:と書いていますが、Usageのところにどうやってspecifyするのか、例がないのでこの以降どうすればよいのか、わかりません。前のバージョン(@@オペレーター)の時は検索出来ていました。<br>&gt; <br>&gt; 上記の例で、target_colの型は「text」で、そのフィールドのindexを作っています。<br>&gt; (CREATE INDEX target_col&nbsp;_index ON db名 USING pgroonga (target_col&nbsp;);)<br><br>ということであれば、target_col &amp;@~
 "東京 OR 大阪" を指定してください。<br>(前のバージョンでできていたというのはちょっとよくわからないのですが。。。)<br><br>&gt; 実行したSQL:<br>&gt; $stmt = $pdo-&gt;prepare("SELECT 項目1、... FROM db名 WHERE target_col&nbsp;&amp;@~ :keyword1 OR :keyword2");<br>&gt; <br>&gt; $stmt-&gt;bindValue(':keyword1', '東京');<br>&gt; <br>&gt; $stmt-&gt;bindValue(':keyword2', '大阪');<br>&gt; <br>&gt; $stmt-&gt;execute();<br><br>なので、上記の箇所も"東京 OR 大阪"となるように以下のようにするとよいはずです。<br><br>$stmt = $dbh-&gt;prepare("SELECT target_col FROM memos WHERE target_col &amp;@~ :keyword");<br>$stmt-&gt;bindValue(':keyword', '東京 OR 大阪');<br>$stmt-&gt;execute();<br><br>サンプルとしては↓な感じでしょうか。<br><br>&nbsp; &lt;?php<br><br>&nbsp; $dsn = 'pgsql:dbname=pgroonga_test host=localhost port=5432';<br>&nbsp; $user =
 'postgres';<br>&nbsp; $password = 'postgres';<br><br>&nbsp; try{<br>&nbsp; &nbsp; $dbh = new PDO($dsn, $user, $password);<br><br>&nbsp; &nbsp; $stmt = $dbh-&gt;prepare("SELECT target_col FROM memos WHERE target_col &amp;@~ :keyword");<br>&nbsp; &nbsp; $stmt-&gt;bindValue(':keyword', '東京 OR 大阪');<br>&nbsp; &nbsp; $stmt-&gt;execute();<br>&nbsp; &nbsp; while ($row = $stmt-&gt;fetch()) {<br>&nbsp; &nbsp; &nbsp; var_dump($row);<br>&nbsp; &nbsp; }<br>&nbsp; } catch (PDOException $e) {<br>&nbsp; &nbsp; print('Error:'.$e-&gt;getMessage());<br>&nbsp; &nbsp; die();<br>&nbsp; }<br>&nbsp; ?&gt;<br><br><br>-- <br>Kentaro Hayashi &lt;<a ymailto="mailto:hayas****@clear*****" href="mailto:hayas****@clear*****" target="_self">hayas****@clear*****</a>&gt;<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>