2
我是elasticsearch的初学者,我想为我在jsonb字段中的字段添加索引。这不是嵌套关系。 (整数)user_id
(整数),data
(jsonb)。在elasticsearch rails中为jsonb字段的属性添加索引
样品jsonb值是这样的:
{"name" => "Test User", "values" => {"age" => 24, "gender" => "male"}, "married": false}
我想为“数据”(jsonb列)的“值”部分中的“性别”字段内添加索引。
数据库是postgres。
我已经加入索引配置如下:
mappings do
indexes :id, type: 'integer'
indexes :user_id, type: 'integer'
indexes :data do
indexes :gender
end
end
这是正确的?
我收到的查询确切的结果,
{"query": {
"term": {
"user_id": 1
}
}}
但不能用于此查询
{"query": {
"term": {
"gender": "male"
}
}}
在此先感谢!
看起来这一个可以帮助你在这里:http://michael.otacoo.com/postgresql-2/postgres-9-4-feature-highlight-indexing-jsonb/ –
@TarynEast ..谢谢..我编辑了这个问题。我正在寻找在elasticsearch中添加索引。 –