Ejemplo n.º 1
0
func (ixWriter *IndexWriter) AddDoc(doc Document) {
	lDoc := C.LucyDocNew(nil, 0) // Are these sane defaults?
	for k, v := range doc {
		name := cb_newf(k)
		value := cb_new_from_utf8(v)
		C.LucyDocStore(lDoc, name, value)
		C.DECREF(name)
		C.DECREF(value)
	}
	C.LucyIndexerAddDoc(ixWriter.lucyIndexer, lDoc, 1.0) // Is 1.0 a sane default?
	C.DECREF(lDoc)
}
Ejemplo n.º 2
0
func (index *Index) GetIndexWriter(flags IndexOpenFlags) IndexWriter {
	idxLocation := cb_newf(index.Location)
	index.lucyIndexer = C.LucyIndexerNew(index.Schema.lucySchema, idxLocation, nil, C.int32_t(flags))
	C.DECREF(idxLocation)
	return func(ixValueColumns ...*IndexValueColumn) {
		doc := C.LucyDocNew(nil, 0)
		for _, ixColumn := range ixValueColumns {
			fieldName := cb_newf(ixColumn.Field)
			fieldValue := cb_new_from_utf8(ixColumn.Value)
			C.LucyDocStore(doc, fieldName, fieldValue)
			C.DECREF(fieldName)
			C.DECREF(fieldValue)
		}
		C.LucyIndexerAddDoc(index.lucyIndexer, doc, 1.0)
		C.DECREF(doc)
	}
}