Beispiel #1
0
func (doc *InventorySearch) Save() ([]search.Field, *search.DocumentMetadata, error) {
	fields, err := search.SaveStruct(doc)
	if err != nil {
		return nil, nil, err
	}
	metadata := &search.DocumentMetadata{Rank: int(doc.Stock)}

	return fields, metadata, nil
}
Beispiel #2
0
// Save with search.DocumentMetadata#Rank.
func (s *InventorySearch) Save() ([]search.Field, *search.DocumentMetadata, error) {
	fields, err := search.SaveStruct(s)
	if err != nil {
		return nil, nil, err
	}
	// https://cloud.google.com/appengine/docs/go/search/reference#DocumentMetadata
	// 0 origin value can not be correctly sorted.
	// Typically, the data is assumed to be 0's origin, 1 added every time.
	metadata := &search.DocumentMetadata{Rank: int(s.Stock) + 1}

	return fields, metadata, nil
}