Exemplo n.º 1
0
func (p *Posting) Init(conf *registry.PostingConfig, reply *bool) error {
	docids, err := document.GetDocids(conf.InitialQuery, p.registry)
	if err != nil {
		return newPostingError("Get Document:", err)
	}
	c := document.GetDocumentsById(docids, p.registry)
	p.lock.Lock()
	defer p.lock.Unlock()
	return p.init(conf, c)
}
Exemplo n.º 2
0
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)
}