mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-26 18:16:47 -05:00
fix(search): keep existing index entries out of the upgrade reindex
This commit is contained in:
1 parent
4e3d952c13
commit
6cfc198663
7 files changed
+7
-50
No files matched your search
@@ -153,7 +153,6 @@ var _ = Describe("Bleve", func() {
|
||||
It("rewrites tags and favorites and keeps the extracted fields", func() {
|
||||
childResource.Content = "quarterly report"
|
||||
childResource.Tags = []string{"alpha"}
|
||||
childResource.Extracted = true
|
||||
Expect(eng.Upsert(childResource.ID, childResource)).To(Succeed())
|
||||
|
||||
Expect(eng.Update(context.Background(), childResource.ID, search.MetadataUpdate{
|
||||
@@ -166,7 +165,6 @@ var _ = Describe("Bleve", func() {
|
||||
Expect(r.Tags).To(Equal([]string{"Beta"}))
|
||||
Expect(r.Favorites).To(Equal([]string{"user-1"}))
|
||||
Expect(r.Content).To(Equal("quarterly report"))
|
||||
Expect(r.Extracted).To(BeTrue())
|
||||
|
||||
Expect(tagHits("beta")).To(ConsistOf("4"), "the lowercase sibling follows the new tag")
|
||||
Expect(tagHits("alpha")).To(BeEmpty())
|
||||
|
||||
@@ -30,19 +30,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"Extracted": {
|
||||
"enabled": true,
|
||||
"dynamic": true,
|
||||
"fields": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"store": true,
|
||||
"index": true,
|
||||
"include_in_all": true,
|
||||
"docvalues": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"Favorites": {
|
||||
"enabled": true,
|
||||
"dynamic": true,
|
||||
|
||||
@@ -156,7 +156,6 @@ var _ = Describe("Backend", func() {
|
||||
document := opensearchtest.Testdata.Resources.File
|
||||
document.Content = "quarterly report"
|
||||
document.Tags = []string{"alpha"}
|
||||
document.Extracted = true
|
||||
Expect(backend.Upsert(document.ID, document)).To(Succeed())
|
||||
|
||||
Expect(backend.Update(context.Background(), document.ID, search.MetadataUpdate{
|
||||
@@ -169,7 +168,6 @@ var _ = Describe("Backend", func() {
|
||||
Expect(r.Tags).To(Equal([]string{"Beta"}))
|
||||
Expect(r.Favorites).To(Equal([]string{"user-1"}))
|
||||
Expect(r.Content).To(Equal("quarterly report"))
|
||||
Expect(r.Extracted).To(BeTrue())
|
||||
|
||||
Expect(tagHits("beta")).To(Equal(1), "the lowercase sibling follows the new tag")
|
||||
Expect(tagHits("alpha")).To(BeZero())
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
"Deleted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Extracted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Favorites": {
|
||||
"type": "keyword"
|
||||
},
|
||||
|
||||
@@ -85,9 +85,6 @@ type Resource struct {
|
||||
Type uint64 `json:"Type"`
|
||||
Deleted bool `json:"Deleted"`
|
||||
Hidden bool `json:"Hidden"`
|
||||
// Extracted is set once the content extraction succeeded, a document
|
||||
// without it is extracted again on the next reindex
|
||||
Extracted bool `json:"Extracted"`
|
||||
}
|
||||
|
||||
// resourceFieldOverrides is built once (it never changes) and reused on hot
|
||||
|
||||
@@ -748,7 +748,6 @@ func (s *Service) doUpsertItem(ctx context.Context, ref *provider.Reference, bat
|
||||
Document: doc,
|
||||
}
|
||||
r.Hidden = IsHidden(r.Path)
|
||||
r.Extracted = true
|
||||
|
||||
if parentID := stat.GetInfo().GetParentId(); parentID != nil {
|
||||
r.ParentID = storagespace.FormatResourceID(parentID)
|
||||
@@ -934,7 +933,7 @@ func (s *Service) MoveItem(ref *provider.Reference) {
|
||||
}
|
||||
}
|
||||
|
||||
// isIndexed reports whether the index holds a live, fully extracted document for info that is at least as new
|
||||
// isIndexed reports whether the index holds a live document for info that is at least as new
|
||||
func (s *Service) isIndexed(ctx context.Context, info *provider.ResourceInfo) bool {
|
||||
r, err := s.engine.Get(ctx, storagespace.FormatResourceID(info.GetId()))
|
||||
switch {
|
||||
@@ -944,7 +943,7 @@ func (s *Service) isIndexed(ctx context.Context, info *provider.ResourceInfo) bo
|
||||
s.logger.Error().Err(err).Interface("id", info.GetId()).Msg("failed to look up the indexed resource, indexing it again")
|
||||
return false
|
||||
}
|
||||
return !r.Deleted && r.Extracted && r.Mtime != nil && !r.Mtime.Before(utils.TSToTime(info.GetMtime()))
|
||||
return !r.Deleted && r.Mtime != nil && !r.Mtime.Before(utils.TSToTime(info.GetMtime()))
|
||||
}
|
||||
|
||||
func (s *Service) resInfo(ctx context.Context, ref *provider.Reference) (*provider.StatResponse, string) {
|
||||
|
||||
@@ -158,14 +158,12 @@ var _ = Describe("Searchprovider", func() {
|
||||
info("outdated", sprovider.ResourceType_RESOURCE_TYPE_FILE, 5000),
|
||||
info("missing", sprovider.ResourceType_RESOURCE_TYPE_FILE, 4000),
|
||||
info("trashed", sprovider.ResourceType_RESOURCE_TYPE_FILE, 4000),
|
||||
info("unextracted", sprovider.ResourceType_RESOURCE_TYPE_FILE, 4000),
|
||||
}
|
||||
indexed := map[string]*search.Resource{
|
||||
"storageid$spaceid!spaceid": {Document: content.Document{Mtime: &indexedAt}, Extracted: true},
|
||||
"storageid$spaceid!current": {Document: content.Document{Mtime: &indexedAt}, Extracted: true},
|
||||
"storageid$spaceid!outdated": {Document: content.Document{Mtime: &indexedAt}, Extracted: true},
|
||||
"storageid$spaceid!trashed": {Document: content.Document{Mtime: &indexedAt}, Extracted: true, Deleted: true},
|
||||
"storageid$spaceid!unextracted": {Document: content.Document{Mtime: &indexedAt}},
|
||||
"storageid$spaceid!spaceid": {Document: content.Document{Mtime: &indexedAt}},
|
||||
"storageid$spaceid!current": {Document: content.Document{Mtime: &indexedAt}},
|
||||
"storageid$spaceid!outdated": {Document: content.Document{Mtime: &indexedAt}},
|
||||
"storageid$spaceid!trashed": {Document: content.Document{Mtime: &indexedAt}, Deleted: true},
|
||||
}
|
||||
|
||||
gatewayClient.On("GetUserByClaim", mock.Anything, mock.Anything).Return(&userv1beta1.GetUserByClaimResponse{
|
||||
@@ -204,7 +202,7 @@ var _ = Describe("Searchprovider", func() {
|
||||
|
||||
err := s.IndexSpace(&sprovider.StorageSpaceId{OpaqueId: "storageid$spaceid!spaceid"}, false)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
Expect(upserted).To(ConsistOf("storageid$spaceid!outdated", "storageid$spaceid!missing", "storageid$spaceid!trashed", "storageid$spaceid!unextracted"))
|
||||
Expect(upserted).To(ConsistOf("storageid$spaceid!outdated", "storageid$spaceid!missing", "storageid$spaceid!trashed"))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -246,22 +244,6 @@ var _ = Describe("Searchprovider", func() {
|
||||
Entry("/", "/", false),
|
||||
)
|
||||
|
||||
It("marks the resource as extracted", func() {
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(&sprovider.StatResponse{
|
||||
Status: status.NewOK(context.Background()),
|
||||
Info: ri,
|
||||
}, nil)
|
||||
extractor.On("Extract", mock.Anything, mock.Anything, mock.Anything).Return(content.Document{}, nil)
|
||||
|
||||
var indexed search.Resource
|
||||
indexClient.On("Upsert", mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
|
||||
indexed = args.Get(1).(search.Resource)
|
||||
}).Return(nil)
|
||||
|
||||
s.UpsertItem(&sprovider.Reference{ResourceId: ri.GetId()})
|
||||
Expect(indexed.Extracted).To(BeTrue())
|
||||
})
|
||||
|
||||
Context("with facets stored on the resource", func() {
|
||||
var (
|
||||
info *sprovider.ResourceInfo
|
||||
@@ -456,7 +438,6 @@ var _ = Describe("Searchprovider", func() {
|
||||
|
||||
s.UpdateMetadata(&sprovider.Reference{ResourceId: info.GetId()})
|
||||
Expect(indexed.ID).To(Equal("storageid$spaceid!tagged-opaqueid"))
|
||||
Expect(indexed.Extracted).To(BeTrue())
|
||||
})
|
||||
|
||||
It("does not extract the content when the update fails for another reason", func() {
|
||||
|
||||
Reference in new issue
Block a user