Implement Remove for removing entries from the index
This commit is contained in:
@@ -64,6 +64,10 @@ func (i *Index) Add(ref *sprovider.Reference, ri *sprovider.ResourceInfo) error
|
||||
return i.bleveIndex.Index(entity.ID, entity)
|
||||
}
|
||||
|
||||
func (i *Index) Remove(ri *sprovider.ResourceInfo) error {
|
||||
return i.bleveIndex.Delete(ri.Id.GetStorageId() + ":" + ri.Id.GetOpaqueId())
|
||||
}
|
||||
|
||||
func (i *Index) Search(ctx context.Context, req *search.SearchIndexRequest) (*search.SearchIndexResult, error) {
|
||||
query := bleve.NewConjunctionQuery(
|
||||
bleve.NewQueryStringQuery(req.Query),
|
||||
|
||||
@@ -90,8 +90,6 @@ var _ = Describe("Index", func() {
|
||||
}
|
||||
})
|
||||
|
||||
PIt("finds directories by prefix")
|
||||
|
||||
Context("and an additional file in a subdirectory", func() {
|
||||
var (
|
||||
nestedRef *sprovider.Reference
|
||||
@@ -187,6 +185,16 @@ var _ = Describe("Index", func() {
|
||||
})
|
||||
|
||||
Describe("Remove", func() {
|
||||
PIt("removes a resource from the index")
|
||||
It("removes a resource from the index", func() {
|
||||
err := i.Add(ref, ri)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
count, _ := bleveIndex.DocCount()
|
||||
Expect(count).To(Equal(uint64(1)))
|
||||
|
||||
err = i.Remove(ri)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
count, _ = bleveIndex.DocCount()
|
||||
Expect(count).To(Equal(uint64(0)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user