2015-04-09 3 views
0

Я загрузил и настроил ElasticSearch. Когда я пытаюсь индексировать экземпляр с помощью клиента elasticsearch i.e Nest, я получаю сообщение «Удаленный сервер возвратил ошибку: (400) Ошибка« Bad Request ». Какая может быть проблема?Плохая ошибка запроса при индексировании

static void Main(string[] args) 
     { 
       const string folderLocation = @"\\c:\elmah-exceptions\"; 
       var ElasticSearchServerURI = "http://localhost:9200"; 
       var defaultIndex = "Prod"; 
       var uri = new Uri(ElasticSearchServerURI); 
       var connectionSettings = new ConnectionSettings(uri, defaultIndex).EnableTrace(true).ExposeRawResponse(true); 
       var elasticClient = new ElasticClient(connectionSettings); 

       var files = GetFiles(folderLocation); 
       foreach (var file in files) 
       { 
        var error = ParseFile(file); 
        if (error != null) 
        { 
         elasticClient.Index(error);//I get an error on this line 
        } 
       }   
     } 

public class Error 
    { 
     public string errorType { get; set; } 
     public string message { get; set; } 
     public string source { get; set; } 
     public string errorArea { get; set; } 

     public string queryString { get; set; } 
     public string siteId { get; set; } 
     public string model { get; set; } 
     public string eolUserName { get; set; } 
     public string name { get; set; } 

     public string httpClientSrcIP { get; set; } 
     public string errorTime { get; set; } 
     public string sessionId { get; set; } 
     public string httpSoapAction { get; set; } 
     public string pathTranslated { get; set; } 
     public string httpReferer { get; set; } 

     public string sessionStartQueryString { get; set; } 

     public string file { get; set; } 
     public string host { get; set; } 
    } 

ответ

3

Исправление состоит в том, что индекс по умолчанию должен быть в нижнем регистре.

static void Main(string[] args) 
     { 
       const string folderLocation = @"\\c:\elmah-exceptions\"; 
       var ElasticSearchServerURI = "http://localhost:9200"; 
       var defaultIndex = "prod"; 
       var uri = new Uri(ElasticSearchServerURI); 
       var connectionSettings = new ConnectionSettings(uri, defaultIndex).EnableTrace(true).ExposeRawResponse(true); 
       var elasticClient = new ElasticClient(connectionSettings); 

       var files = GetFiles(folderLocation); 
       foreach (var file in files) 
       { 
        var error = ParseFile(file); 
        if (error != null) 
        { 
         elasticClient.Index(error);//I get an error on this line 
        } 
       }   
     } 

public class Error 
    { 
     public string errorType { get; set; } 
     public string message { get; set; } 
     public string source { get; set; } 
     public string errorArea { get; set; } 

     public string queryString { get; set; } 
     public string siteId { get; set; } 
     public string model { get; set; } 
     public string eolUserName { get; set; } 
     public string name { get; set; } 

     public string httpClientSrcIP { get; set; } 
     public string errorTime { get; set; } 
     public string sessionId { get; set; } 
     public string httpSoapAction { get; set; } 
     public string pathTranslated { get; set; } 
     public string httpReferer { get; set; } 

     public string sessionStartQueryString { get; set; } 

     public string file { get; set; } 
     public string host { get; set; } 
    }