예제 #1
0
파일: indexer.go 프로젝트: postfix/golucy
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)
}
예제 #2
0
파일: index.go 프로젝트: rectang/golucy
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)
	}
}