func TestCorpus(item *QueueItem, registry *registry.Registry, client *posting.Client, c chan *QueueItemRun) { docs := document.BuildTestCorpus(10, 20, 5000) for doc := <-docs; doc != nil; doc = <-docs { if err := doc.Save(registry); err != nil { c <- runFailure(item, "Save Document", err) return } if err := client.CallMultiple("Posting.Add", &document.DocumentArg{Id: &doc.Id}); err != nil { c <- runFailure(item, "RPC Call", err) return } } c <- runSuccess(item) }
func DeleteDocument(item *QueueItem, registry *registry.Registry, client *posting.Client, c chan *QueueItemRun) { doc, err := document.GetDocument(item.Target, registry) if err != nil { c <- runFailure(item, "Get Document", err) return } if err = client.CallMultiple("Posting.Delete", &document.DocumentArg{Id: &doc.Id}); err != nil { c <- runFailure(item, "RPC Call", err) return } if err = doc.Delete(registry); err != nil { c <- runFailure(item, "Delete Document", err) return } c <- runSuccess(item) }
func AddDocument(item *QueueItem, registry *registry.Registry, client *posting.Client, c chan *QueueItemRun) { values, err := item.PayloadValues() if err != nil { c <- runFailure(item, "Get Payload", err) return } doc, err := document.NewDocument(item.Target, values) if err != nil { c <- runFailure(item, "New Document", err) return } if err = doc.Save(registry); err != nil { c <- runFailure(item, "Save Document", err) return } if err = client.CallMultiple("Posting.Add", &document.DocumentArg{Id: &doc.Id}); err != nil { c <- runFailure(item, "RPC Call", err) return } c <- runSuccess(item) }
func AssociateDocument(item *QueueItem, registry *registry.Registry, client *posting.Client, c chan *QueueItemRun) { var err error var source []document.DocumentID if item.Source != nil { source = []document.DocumentID{*item.Source} } if item.SourceRange != "" { if source, err = document.GetDocids(item.SourceRange, registry); err != nil { c <- runFailure(item, "Get Source Range", err) } } fmt.Println(source, item.Target, item.TargetRange) for _, s := range source { doc := &document.DocumentArg{Id: &s, TargetRange: item.TargetRange} result, err := client.Search(doc) if err != nil { c <- runFailure(item, "Search", err) } if _, err := result.GetResult(registry, doc, true); err != nil { c <- runFailure(item, "Get Result", err) } } c <- runSuccess(item) }