[groonga-dev,04425] Re: &@~オペレーターのUndefined function: 7 ERROR: operator does not exist:エラー

Back to archive index

s400t****@yahoo***** s400t****@yahoo*****
2017年 8月 2日 (水) 20:17:50 JST


お返事、ありがとうございます。

>(前のバージョンでできていたというのはちょっとよくわからないのですが。。。)
@@オペレーター使って、以前は検索出来ていたということです。

か、
今日また@@オペレーター使ってみたら、正常に検索出来ています。

で、なんで&@~オペレーターを使ったのか:
どこかで、「この演算子=@@のこと=は1.2.0から非推奨です。代わりに&@~演算子を使ってください。」と書いていたので。

今日、@@オペレーターで正常に検索出来たのはbackward compatibilityのおかげでしょうか。

項目1 or 項目2検索で、いつかは「&@~」オペレーターしか使えないのなら、今からでもそのオペレーターを使った方が良いでしょうと思って、試したのです。


今日は、phpPgAdminコンソールのsql実行するところで、直接sql実行したました。
林さんが書いてくださったサンプルのsql文ですが、bindValueなしで、

SELECT * FROM memos WHERE target_col &@~ '東京 OR 大阪';


↑を実行しました。

結果は前回と同じエラーです。

エラー:

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.






----- Original Message -----
>From: Kentaro Hayashi <hayas****@clear*****>
>To: groon****@lists***** 
>Date: 2017/8/2, Wed 11:40
>Subject: [groonga-dev,04424] Re: &@~オペレーターのUndefined function: 7 ERROR: operator does not exist:エラー
> 
>林です。
>
>On Mon, 31 Jul 2017 19:39:15 +0900 (JST)
>s400t****@yahoo***** wrote:
>
>> MLみなさん
>> こんにちは。
>> 
>> 1っか月+にまたpgroonga試して見ました。
>> 二つ単語検索のOR条件に&@~オペレーター使おうとしていますが、エラーになります。
>> 
>
>
>> 例) target_col列の'東京'又は'大阪'をヒットさせて、一覧取得しようとしています。
>> 
>> https://pgroonga.github.io/reference/operators/query-v2.htmlの「Operator classes」のところ:
>> 
>> You need to specify one of the following operator classes to use this operator:と書いていますが、Usageのところにどうやってspecifyするのか、例がないのでこの以降どうすればよいのか、わかりません。前のバージョン(@@オペレーター)の時は検索出来ていました。
>> 
>> 上記の例で、target_colの型は「text」で、そのフィールドのindexを作っています。
>> (CREATE INDEX target_col _index ON db名 USING pgroonga (target_col );)
>
>ということであれば、target_col &@~ "東京 OR 大阪" を指定してください。
>(前のバージョンでできていたというのはちょっとよくわからないのですが。。。)
>
>> 実行したSQL:
>> $stmt = $pdo->prepare("SELECT 項目1、... FROM db名 WHERE target_col &@~ :keyword1 OR :keyword2");
>> 
>> $stmt->bindValue(':keyword1', '東京');
>> 
>> $stmt->bindValue(':keyword2', '大阪');
>> 
>> $stmt->execute();
>
>なので、上記の箇所も"東京 OR 大阪"となるように以下のようにするとよいはずです。
>
>$stmt = $dbh->prepare("SELECT target_col FROM memos WHERE target_col &@~ :keyword");
>$stmt->bindValue(':keyword', '東京 OR 大阪');
>$stmt->execute();
>
>サンプルとしては↓な感じでしょうか。
>
>  <?php
>
>  $dsn = 'pgsql:dbname=pgroonga_test host=localhost port=5432';
>  $user = 'postgres';
>  $password = 'postgres';
>
>  try{
>    $dbh = new PDO($dsn, $user, $password);
>
>    $stmt = $dbh->prepare("SELECT target_col FROM memos WHERE target_col &@~ :keyword");
>    $stmt->bindValue(':keyword', '東京 OR 大阪');
>    $stmt->execute();
>    while ($row = $stmt->fetch()) {
>      var_dump($row);
>    }
>  } catch (PDOException $e) {
>    print('Error:'.$e->getMessage());
>    die();
>  }
>  ?>
>
>
>-- 
>Kentaro Hayashi <hayas****@clear*****>
>
>_______________________________________________
>groonga-dev mailing list
>groon****@lists*****
>http://lists.osdn.me/mailman/listinfo/groonga-dev
>
>
>
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Descargar 



groonga-dev メーリングリストの案内
Back to archive index