【发布时间】:2013-12-22 15:45:03
【问题描述】:
我正在寻找一些关于如何开始满足以下要求的高级建议:
我们有一个运行在 heroku 上的 ruby sinatra API 服务,可以将用户的电子邮件与我们的系统同步。
我们将用户的电子邮件存储在 postgres 数据库中,该数据库分为主题、文本和 html 字段。
我想使用 elasticsearch 搜索这些电子邮件,但搜索只能搜索用户收件箱中的电子邮件。
谁能告诉我如何索引 postgres 电子邮件表以及如何过滤搜索以使其仅限于用户电子邮件的第一步?
电子邮件表的架构是:
CREATE TABLE emails
(
id serial NOT NULL,
subject text,
body text,
personal boolean,
sent_at timestamp without time zone,
created_at timestamp without time zone,
updated_at timestamp without time zone,
addresses text,
account_id integer NOT NULL,
sender_user_id integer,
sender_contact_id integer,
html text,
folder text,
draft boolean DEFAULT false,
check_for_response timestamp without time zone,
send_time timestamp without time zone,
send_time_jid text,
check_for_response_jid text,
message_id text,
in_reply_to text,
CONSTRAINT emails_pkey PRIMARY KEY (id),
CONSTRAINT emails_account_id_fkey FOREIGN KEY (account_id)
REFERENCES accounts (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE,
CONSTRAINT emails_sender_contact_id_fkey FOREIGN KEY (sender_contact_id)
REFERENCES contacts (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE,
CONSTRAINT emails_sender_user_id_fkey FOREIGN KEY (sender_user_id)
REFERENCES users (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
)
【问题讨论】:
-
电子邮件数据库的架构是什么?
-
@kielni 我已经用架构更新了问题
标签: ruby heroku sinatra elasticsearch