仅在创建新记录后,新记录就不会出现在列表api中,尽管它已被索引。再次点击索引api时出现新记录。使用通过searchkick实现的弹性搜索。有人遇到过这个问题吗?
Started POST "/api/v1/pm/projects/4/meetings" for 127.0.0.1 at 2018-10-12 13:15:45 +0530
Processing by Api::V1::Pm::MeetingsController#create as JSON
Parameters: {"meeting"=>{"name"=>"prj 4 meeting 78", "date"=>"12/10/2018", "start_time"=>"01:30 PM", "end_time"=>"02:00 PM", "url"=>"https://asdf.com", "agenda"=>"prj 4 meeting 78 agenda", "notes"=>"", "members"=>["abc@gmail.com"]}, "project_id"=>"4"}
AuthenticationToken Load (0.2ms) SELECT "authentication_tokens".* FROM "authentication_tokens" WHERE "authentication_tokens"."body" = $1 LIMIT $2 [["body", "Eu5fwDmEkLDootjzE3kcUrGi"], ["LIMIT", 1]]
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 AND "users"."is_approved" = $2 AND "users"."is_archived" = $3 LIMIT $4 [["id", 1], ["is_approved", "t"], ["is_archived", "f"], ["LIMIT", 1]]
Partner Load (0.2ms) SELECT "partners".* FROM "partners" WHERE "partners"."code" = $1 LIMIT $2 [["code", "e-ai"], ["LIMIT", 1]]
Project Load (0.6ms) SELECT "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT $2 [["id", 4], ["LIMIT", 1]]
(0.2ms) BEGIN
SQL (1.7ms) INSERT INTO "meetings" ("name", "date", "start_time", "end_time", "url", "agenda", "notes", "members", "project_id", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING "id" [["name", "prj 4 meeting 78"], ["date", "2018-10-12"], ["start_time", "13:30:00"], ["end_time", "14:00:00"], ["url", "https://asdf.com"], ["agenda", "prj 4 meeting 78 agenda"], ["notes", ""], ["members", "{abc@gmail.com}"], ["project_id", 4], ["user_id", 1], ["created_at", "2018-10-12 07:45:45.133414"], ["updated_at", "2018-10-12 07:45:45.133414"]]
(10.7ms) COMMIT
***Meeting Store (77.8ms) {"id":78}***
[active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (1.81ms)
Completed 200 OK in 116ms (Views: 3.5ms | Searchkick: 77.8ms | ActiveRecord: 13.9ms)
Started GET "/api/v1/pm/projects/4/meetings" for 127.0.0.1 at 2018-10-12 13:15:45 +0530
Processing by Api::V1::Pm::MeetingsController#index as JSON
Parameters: {"project_id"=>"4", "meeting"=>{}}
AuthenticationToken Load (0.3ms) SELECT "authentication_tokens".* FROM "authentication_tokens" WHERE "authentication_tokens"."body" = $1 LIMIT $2 [["body", "Eu5fwDmEkLDootjzE3kcUrGi"], ["LIMIT", 1]]
User Load (1.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 AND "users"."is_approved" = $2 AND "users"."is_archived" = $3 LIMIT $4 [["id", 1], ["is_approved", "t"], ["is_archived", "f"], ["LIMIT", 1]]
Partner Load (1.0ms) SELECT "partners".* FROM "partners" WHERE "partners"."code" = $1 LIMIT $2 [["code", "e-ai"], ["LIMIT", 1]]
Project Load (0.6ms) SELECT "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT $2 [["id", 4], ["LIMIT", 1]]
Meeting Search (16.8ms) curl http://localhost:9200/meetings_development/_search?pretty -H 'Content-Type: application/json' -d '{"query":{"bool":{"must":{"match_all":{}},"filter":[{"term":{"project_id":4}}]}},"sort":{"cancelled_at":{"order":"asc","unmapped_type":"boolean"},"updated_at":{"order":"desc","unmapped_type":"long"}},"timeout":"11s","_source":false,"size":25,"from":0}'
Meeting Load (1.8ms) SELECT "meetings".* FROM "meetings" WHERE "meetings"."id" IN (77, 75, 76, 74, 73, 72, 71, 70)
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1
[active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (13.02ms)
Completed 200 OK in 52ms (Views: 14.4ms | Searchkick: 16.8ms | ActiveRecord: 5.5ms)
您会在日志中看到ID为78的会议正在被索引但未出现在索引api中。
答案 0 :(得分:0)
Elasticsearch是近实时(NRT)搜索平台。这是什么意思 从您开始算起是否有轻微的延迟(通常是一秒钟) 为文档建立索引,直到可以搜索为止。 NRT
如果您可以改用批量API,因为索引编制的时间比一次记录的速度更快。
例如,更新设置API可用于动态更改 索引从对批量索引的性能更高的方面开始,然后移动 它可以更实时地建立索引状态。在批量索引之前 开始使用:
PUT /twitter/_settings
{
"index" : {
"refresh_interval" : "-1"
}
}
检查文档。 refresh_interval
并查看此讨论discussion