If two fields are queried, the first is used as an index.
330768
function queryColumn($query)
  {
    $data = [];
    $res = $this->q($query);
    while ($row = $res->fetch_row())
    {
      if ($res->field_count == 1)
        $data[] = $row[0];
      else
        $data[$row[0]] = $row[1];
    }
    $res->close();
    return $data;
  }
1143801
function sortFieldsByIndex(userFields, index) {
  var indexFields = index.def.fields.map(getKey);

  return userFields.slice().sort(function (a, b) {
    var aIdx = indexFields.indexOf(a);
    var bIdx = indexFields.indexOf(b);
    if (aIdx === -1) {
      aIdx = Number.MAX_VALUE;
    }
    if (bIdx === -1) {
      bIdx = Number.MAX_VALUE;
    }
    return utils.compare(aIdx, bIdx);
  });
}
1057426
public QueryBuilder useIndex(String designDocument, String indexName) {
        useIndex = new String[]{designDocument, indexName};
        return this;
    }
577084
def _generate_index_report(self, index, query_analysis):
        """"""

        all_fields = []
        equiv_fields = []
        sort_fields = []
        range_fields = []

        for query_field in query_analysis['analyzedFields']:
            all_fields.append(query_field['fieldName'])
            if query_field['fieldType'] is EQUIV_TYPE:
                equiv_fields.append(query_field['fieldName'])
            elif query_field['fieldType'] is SORT_TYPE:
                sort_fields.append(query_field['fieldName'])
            elif query_field['fieldType'] is RANGE_TYPE:
                range_fields.append(query_field['fieldName'])

        max_equiv_seq = len(equiv_fields)
        max_sort_seq = max_equiv_seq + len(sort_fields)
        max_range_seq = max_sort_seq + len(range_fields)

        coverage = 'none'
        query_fields_covered = 0
        query_field_count = query_analysis['fieldCount']
        supported = True
        ideal_order = True
        for index_field in index['key']:
            field_name = index_field[0]

            if index_field[1] == '2d':
                supported = False
                break

            if field_name not in all_fields:
                break

            if query_fields_covered == 0:
                coverage = 'partial'

            if query_fields_covered < max_equiv_seq:
                if field_name not in equiv_fields:
                    ideal_order = False
            elif query_fields_covered < max_sort_seq:
                if field_name not in sort_fields:
                    ideal_order = False
            elif query_fields_covered < max_range_seq:
                if field_name not in range_fields:
                    ideal_order = False
            query_fields_covered += 1
        if query_fields_covered == query_field_count:
            coverage = 'full'

        # INDEX REPORT
        return OrderedDict({
            'coverage': coverage,
            'idealOrder': ideal_order,
            'queryFieldsCovered': query_fields_covered,
            'index': index,
            'supported': supported
        })
1280922
public boolean indexAppliesTo( Constraint constraint ) {
        if (constraint instanceof Comparison) {
            return indexAppliesTo((Comparison)constraint);
        }
        if (constraint instanceof And) {
            return indexAppliesTo((And)constraint);
        }
        if (constraint instanceof Or) {
            return indexAppliesTo((Or)constraint);
        }
        if (constraint instanceof Not) {
            return indexAppliesTo((Not)constraint);
        }
        if (constraint instanceof Between) {
            return indexAppliesTo((Between)constraint);
        }
        if (constraint instanceof SetCriteria) {
            return indexAppliesTo((SetCriteria)constraint);
        }
        if (constraint instanceof Relike) {
            return indexAppliesTo((Relike)constraint);
        }
        if (constraint instanceof PropertyExistence) {
            return indexAppliesTo((PropertyExistence)constraint);
        }
        if (constraint instanceof FullTextSearch) {
            return applies((FullTextSearch)constraint);
        }
        return false;
    }
962985
public void createIndex(DBObject keys, DBObject options) throws MongoException {
        dbCollection.createIndex(keys, options);
    }
57883
private Indexer getDefaultIndexer(Field field) {
    Type type = field.getGenericType();
    if (type instanceof Class && type.equals(String.class)) {
      return getIndexer(LowerCaseStringIndexer.class);
    } else if (type instanceof ParameterizedType) {
      ParameterizedType parameterizedType = (ParameterizedType) type;
      Class<?> rawType = (Class<?>) parameterizedType.getRawType();
      if (List.class.isAssignableFrom(rawType) || Set.class.isAssignableFrom(rawType)) {
        Class<?>[] collectionType = IntrospectionUtils.resolveCollectionType(type);
        if (String.class.equals(collectionType[1])) {
          return getIndexer(LowerCaseStringListIndexer.class);
        }
      }
    }
    String message = String.format("No default indexer found for field %s in class %s",
        field.getName(), field.getDeclaringClass().getName());
    throw new NoSuitableIndexerException(message);
  }
935947
private int mapIndexToAction(int index) {
    if (index < buttonCount) {
      int count = -1;
      for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
        if (fields[x]) {
          count++;
        }
        if (count == index) {
          return x;
        }
      }
    }
    return -1;
  }
262654
public int convertIndexToField(int index, boolean bDisplayOption, int iMoveMode)
    {
        String tempString = this.convertIndexToString(index);
        return this.setString(tempString, bDisplayOption, iMoveMode); // Move value to this field
    }
507487
def query(self, search, query):
        
        if query:
            if self.fields:
                return search.query('multi_match', fields=self.fields, query=query)
            else:
                return search.query('multi_match', query=query)
        return search
1328758
public int convertIndexToField(int index, boolean bDisplayOption, int iMoveMode)
    {   // User selected an item... Read it in!
        int iErrorCode = this.moveToIndex(index);
        if (iErrorCode == DBConstants.NORMAL_RETURN)
            m_record.handleRecordChange(null, DBConstants.SELECT_TYPE, bDisplayOption);   // Record selected!!!
        // These next lines causes the FieldBehaviors with SCREEN_MOVE to be executed!!!
        FieldInfo field = this.getField();
        if (iErrorCode == DBConstants.NORMAL_RETURN) if (field != null)
        {
            if (field instanceof ReferenceField)
                ((ReferenceField)field).setReference(m_record, bDisplayOption, iMoveMode);
            else if (field instanceof StringField)
            {
                {
                    if (displayFieldName != null)
                        return field.setString(m_record.getField(displayFieldName).toString());
                    else
                        return field.setString(m_record.getField(m_iFieldSeq).toString());
                }
            }
        }
        return iErrorCode;
    }
1265267
public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case START_ROW_OFFSET:
      return isSetStartRowOffset();
    case ROWS:
      return isSetRows();
    case COLUMNS:
      return isSetColumns();
    }
    throw new IllegalStateException();
  }
267129
def VcardFieldsEqual(field1, field2):
    
    field1_vals = set([ str(f.value) for f in field1 ])
    field2_vals = set([ str(f.value) for f in field2 ])
    if field1_vals == field2_vals:
        return True
    else:
        return False
94377
private ResourceField selectField(ResourceField[] fields, int index)
   {
      if (index < 1 || index > fields.length)
      {
         throw new IllegalArgumentException(index + " is not a valid field index");
      }
      return (fields[index - 1]);
   }
1350786
def _set_index(self, schema, name, fields, **index_options):
        
        query_str = "CREATE {}INDEX IF NOT EXISTS '{}_{}' ON {} ({})".format(
            'UNIQUE ' if index_options.get('unique', False) else '',
            schema,
            name,
            self._normalize_table_name(schema),
            ', '.join((self._normalize_name(f) for f in fields))
        )

        return self._query(query_str, ignore_result=True, **index_options)
598432
public OSchemaHelper oIndex(String name, INDEX_TYPE type, String... fields)
	{
		checkOClass();
		lastIndex = lastClass.getClassIndex(name);
		if(lastIndex==null)
		{
			lastIndex = lastClass.createIndex(name, type, fields);
		}
		else
		{
			//We can't do something to change type and fields if required
		}
		return this;
	}
567308
def more_than_one_index(s, brackets=2):
    '''
    
    '''
    start = 0
    brackets_num = 0
    while start != -1 and brackets_num < brackets:
        start = s.find("[", start)
        if start == -1:
            break
        start = s.find("]", start)
        brackets_num += 1
    if start != -1:
        return True
    return False