}
                $sphinxConfigurationIndexs[$index][$schemaFieldName] = $schemaFieldValue;
            } elseif ($schemaFieldName == 'fields') {
                foreach ($schemaFieldValue as $schemaSubFieldName => $schemaSubFieldValue) {
                    if (isset($sphinxConfigurationIndexs[$index][$schemaFieldName][$schemaSubFieldName])) {
                        throw new Exception('duplicated fields ' . $schemaFieldName . ' for index ' . $index);
                    }
                    $sphinxConfigurationIndexs[$index][$schemaFieldName][$schemaSubFieldName] = $schemaSubFieldValue;
                }
            }
        }
    }
}
foreach ($sphinxConfigurationIndexs as $sphinxIndexName => $sphinxIndexValues) {
    // applies default values
    $sphinxIndexValues = kSphinxSearchManager::getSphinxDefaultConfig($sphinxIndexValues);
    fwrite($sphinxConfigHandler, 'index ' . $sphinxIndexName . PHP_EOL . '{' . PHP_EOL);
    foreach ($sphinxIndexValues as $key => $value) {
        if ($key == 'fields') {
            foreach ($value as $fieldValue => $fieldName) {
                fwrite($sphinxConfigHandler, "\t" . $fieldName . "\t" . ' = ' . $fieldValue . PHP_EOL);
            }
        } else {
            if ($key == 'path') {
                $value = $baseDir . $value;
            }
            fwrite($sphinxConfigHandler, "\t" . $key . "\t" . ' = ' . $value . PHP_EOL);
        }
    }
    fwrite($sphinxConfigHandler, '}' . PHP_EOL);
}