Beispiel #1
0
func stringSpecType(field *Field) *C.CFishCharBuf {
	return C.LucyStringTypeInitOptions(
		C.LucyStringTypeNew(),
		(C.float)(field.IndexOptions.Boost),
		(C.bool)(field.IndexOptions.Indexed),
		(C.bool)(field.IndexOptions.Stored),
		(C.bool)(field.IndexOptions.Sortable),
	)
}
Beispiel #2
0
func stringSpecType(field *Field) *C.lucy_FieldType {
	return (*C.lucy_FieldType)(C.LucyStringTypeInitOptions(
		C.LucyStringTypeNew(),
		(C.float)(field.IndexOptions.Boost),
		(C.bool)(field.IndexOptions.Indexed),
		(C.bool)(field.IndexOptions.Stored),
		(C.bool)(field.IndexOptions.Sortable),
	))
}
Beispiel #3
0
func (schema *Schema) createLucySchema() {
	lucySchema := C.LucySchemaNew()
	for _, item := range schema.PlanItems {
		var specType *C.CFishObj
		if item.Type == FullTextType {
			var language *C.CFishCharBuf
			if item.Options != nil && item.Options.Language != "" {
				language = cb_newf(item.Options.Language)
			} else {
				language = cb_newf("en")
			}
			analyzer := C.LucyEasyAnalyzerNew(language)
			specType = C.LucyFullTextTypeNew(analyzer)
			// TODO: come up with a better way to handle options.
			// This isn't very friendly.
			if item.Options != nil {
				specType = C.LucyFullTextTypeInitOptions(specType, analyzer,
					(C.float)(item.Options.Boost),
					(C.bool)(item.Options.Indexed),
					(C.bool)(item.Options.Stored),
					(C.bool)(item.Options.Sortable),
					(C.bool)(item.Options.Highlightable),
				)
			}
			C.DECREF(language)
			C.DECREF(analyzer)
		} else if item.Type == StringType {
			specType = C.LucyStringTypeNew()
			if item.Options != nil {
				specType = C.LucyStringTypeInitOptions(specType,
					(C.float)(item.Options.Boost),
					(C.bool)(item.Options.Indexed),
					(C.bool)(item.Options.Stored),
					(C.bool)(item.Options.Sortable),
				)
			}
		} else if item.Type == BlobType {
			isStored := (C.bool)(false)
			if item.Options != nil && item.Options.Stored {
				isStored = (C.bool)(true)
			}
			specType = C.LucyBlobTypeNew(isStored)
			// need to send []cfish_byte castable value
			panic("BlobType not supported yet")
		} else {
			panic("Type not supported yet")
		}
		fieldName := cb_newf(item.Field)
		C.LucySchemaSpecField(lucySchema, fieldName, specType)
		C.DECREF(fieldName)
		C.DECREF(specType)
	}
	schema.lucySchema = lucySchema
}