// Index returns the position of the first element within the Selection object
// relative to its sibling elements.
423253
func (s *Selection) Index() int {
	if len(s.Nodes) > 0 {
		return newSingleSelection(s.Nodes[0], s.document).PrevAll().Length()
	}
	return -1
}
1183970
func (s *UpdateByQueryService) Index(index ...string) *UpdateByQueryService {
	s.index = append(s.index, index...)
	return s
}
1040981
func index(l []interface{}, valToLookUp interface{}, mergeKey string, kind reflect.Kind) int {
	var getValFn func(interface{}) interface{}
	// Get the correct `getValFn` based on item `kind`.
	// It should return the value of merge key for maps and
	// return the item for other kinds.
	switch kind {
	case reflect.Map:
		getValFn = func(item interface{}) interface{} {
			typedItem, ok := item.(map[string]interface{})
			if !ok {
				return nil
			}
			val := typedItem[mergeKey]
			return val
		}
	default:
		getValFn = func(item interface{}) interface{} {
			return item
		}
	}

	for i, v := range l {
		if getValFn(valToLookUp) == getValFn(v) {
			return i
		}
	}
	return -1
}
759375
func (s *GetMappingService) Index(index ...string) *GetMappingService {
	s.index = append(s.index, index...)
	return s
}
1256172
func index(tokens []string, sep string) int {
	for index, token := range tokens {
		if token == sep {
			return index
		}
	}
	return -1
}
635234
func (s *MultiTermvectorService) Index(index string) *MultiTermvectorService {
	s.index = index
	return s
}
1205689
func (s *PercolateService) Index(index string) *PercolateService {
	s.index = index
	return s
}
543768
func (r *Router) Index() map[string]string {
	index := r.index

	// Recursion
	for _, sr := range r.children {
		si := sr.Index()

		for k, v := range si {
			index[k] = v
		}
	}

	// Sort
	sorted := make(map[string]string)
	var keys []string
	for k := range index {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	for _, k := range keys {
		sorted[k] = index[k]
	}

	return sorted
}
324619
func (b *UpdateService) Index(name string) *UpdateService {
	b.index = name
	return b
}
340773
func Index(limit, offset, length int) (start, end int) {
	if offset > length {
		return length, length
	} else if limit+offset > length {
		return offset, length
	}

	return offset, offset + limit
}
1240787
func (vm *ViewLists) index(tag string) (int, bool) {
	var ind int
	var ok bool

	vm.mo.RLock()
	ind, ok = vm.keys[tag]
	vm.mo.RUnlock()
	return ind, ok
}
1073710
func (r *SearchRequest) Index(indices ...string) *SearchRequest {
	r.indices = append(r.indices, indices...)
	return r
}
1295313
func (r *ReindexDestination) Index(index string) *ReindexDestination {
	r.index = index
	return r
}
703841
func (s *CountService) Index(index string) *CountService {
	if s.index == nil {
		s.index = make([]string, 0)
	}
	s.index = append(s.index, index)
	return s
}
984082
func (s *IndicesFreezeService) Index(index string) *IndicesFreezeService {
	s.index = index
	return s
}
1169760
func (r *ChartRepository) Index() error {
	err := r.generateIndex()
	if err != nil {
		return err
	}
	return r.saveIndexFile()
}
1337781
func (g *Group) Index(items ...Code) *Statement {
	s := Index(items...)
	g.items = append(g.items, s)
	return s
}