// Index indexes a Document
// The extraArgs is a list of url.Values that you can send to elasticsearch as
// URL arguments, for example, to control routing, ttl, version, op_type, etc.
343950
func (c *Connection) Index(d Document, extraArgs url.Values) (*Response, error) {
	r := Request{
		Conn:      c,
		Query:     d.Fields,
		IndexList: []string{d.Index.(string)},
		TypeList:  []string{d.Type},
		ExtraArgs: extraArgs,
		method:    "POST",
	}

	if d.Id != nil {
		r.method = "PUT"
		r.id = d.Id.(string)
	}

	return r.Run()
}
1183970
func (s *UpdateByQueryService) Index(index ...string) *UpdateByQueryService {
	s.index = append(s.index, index...)
	return s
}
496105
func (s *DeleteMappingService) Index(index ...string) *DeleteMappingService {
	s.index = append(s.index, index...)
	return s
}
230631
func (s *IndicesFlushService) Index(indices ...string) *IndicesFlushService {
	s.index = append(s.index, indices...)
	return s
}
154145
func (c *Conn) AnalyzeIndices(index string, args map[string]interface{}) (AnalyzeResponse, error) {
	var retval AnalyzeResponse
	if len(args["text"].(string)) == 0 {
		return retval, errors.New("text to analyze must not be blank")
	}
	var analyzeUrl string = "/_analyze"
	if len(index) > 0 {
		analyzeUrl = fmt.Sprintf("/%s/%s", index, analyzeUrl)
	}

	body, err := c.DoCommand("GET", analyzeUrl, args, nil)
	if err != nil {
		return retval, err
	}
	if err == nil {
		// marshall into json
		jsonErr := json.Unmarshal(body, &retval)
		if jsonErr != nil {
			return retval, jsonErr
		}
	}
	return retval, err
}
22689
func (g *Container) Index(index int) *Container {
	if array, ok := g.Data().([]interface{}); ok {
		if index >= len(array) {
			return &Container{nil}
		}
		return &Container{array[index]}
	}
	return &Container{nil}
}
1256172
func index(tokens []string, sep string) int {
	for index, token := range tokens {
		if token == sep {
			return index
		}
	}
	return -1
}
186567
func (i *indexImpl) Index(id string, data interface{}) (err error) {
	if id == "" {
		return ErrorEmptyID
	}

	i.mutex.RLock()
	defer i.mutex.RUnlock()

	if !i.open {
		return ErrorIndexClosed
	}

	doc := document.NewDocument(id)
	err = i.m.MapDocument(doc, data)
	if err != nil {
		return
	}
	err = i.i.Update(doc)
	return
}
543994
func (m *MapOfCharacterToGlyphIndex) Index(k rune) (int, bool) {
	/*for i, key := range m.Keys {
		if k == key {
			return i, true
		}
	}*/
	if index, ok := m.keyIndexs[k]; ok {
		return index, true
	}
	return -1, false
}
42615
func (b *IndicesCreateService) Index(index string) *IndicesCreateService {
	b.index = index
	return b
}
759375
func (s *GetMappingService) Index(index ...string) *GetMappingService {
	s.index = append(s.index, index...)
	return s
}
1190876
func (s *ExplainService) Index(index string) *ExplainService {
	s.index = index
	return s
}
1337781
func (g *Group) Index(items ...Code) *Statement {
	s := Index(items...)
	g.items = append(g.items, s)
	return s
}
1169760
func (r *ChartRepository) Index() error {
	err := r.generateIndex()
	if err != nil {
		return err
	}
	return r.saveIndexFile()
}
77181
func (cmd *CLI) Arg(index int) values.Value {
	return cmd.Args()[index]
}
93537
func (s *IndicesCloseService) Index(index string) *IndicesCloseService {
	s.index = index
	return s
}
32206
func (c *threadSafeMap) Index(indexName string, obj interface{}) ([]interface{}, error) {
	c.lock.RLock()
	defer c.lock.RUnlock()

	indexFunc := c.indexers[indexName]
	if indexFunc == nil {
		return nil, fmt.Errorf("Index with name %s does not exist", indexName)
	}

	indexKeys, err := indexFunc(obj)
	if err != nil {
		return nil, err
	}
	index := c.indices[indexName]

	// need to de-dupe the return list.  Since multiple keys are allowed, this can happen.
	returnKeySet := sets.String{}
	for _, indexKey := range indexKeys {
		set := index[indexKey]
		for _, key := range set.List() {
			returnKeySet.Insert(key)
		}
	}

	list := make([]interface{}, 0, returnKeySet.Len())
	for absoluteKey := range returnKeySet {
		list = append(list, c.items[absoluteKey])
	}
	return list, nil
}