[groonga-dev,00470] referenceでの検索

Back to archive index

Endo Akira endo4****@goo*****
2011年 3月 30日 (水) 08:52:30 JST


須藤様

遠藤です。お言葉に甘え、まずはreferenceのvectorの使い方を教えてください。
そもそもは、referenceのvectorができないのかと勘違いしましたが、できる、
と信じたらできました。がその先が分かりません。

require 'rubygems'
require 'groonga'
Groonga::Context.default_options = {encoding: :utf8}
Groonga::Database.create(path: "db/bookmark.db")
Groonga::Schema.create_table("pis", type: :hash) do |table|
  table.short_text("jan")
end
Groonga::Schema.create_table("items", type: :hash) do |table|
  table.reference("pisrefs", "pis", type: :vector)
end
Groonga::Schema.create_table("Terms",type: :patricia_trie,
  key_normalize: true, default_tokenizer: "TokenBigram") do |table|
  table.index("pis.jan")
end
items = Groonga["items"]
pis = Groonga["pis"]
p0 = pis.add("0", jan: '123')
p1 = pis.add("1", jan: '234')
items.add("0", pisrefs: [p0,p1])
p items["0"].pisrefs.class #=> Array
p items["0"].pisrefs[0].jan #=> '123'
p items.select{|r|
  res = false
  r.pisrefs.each{|p|       #######
    res |= p.jan =~ '123'
  }
  res
}

以上、itemsテーブルにpisテーブルへのreferenceをvectorでいれた
つもりですが、#######のところで、
undefined method 'each' for #<Groonga::ExpressionBuildable::ColumnValueExpressionBuilder:0x000000029e8868
というエラーが出ます。selectの中では、挙動が変わるようで、ここから進めません。




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