I have setup MongoDB database with Enron mail collection. MongoRiver is used to bridge between Mongo & ElasticSearch. I can access the Mongo Data via REST on ElasticSearch.
While configuring MongoRiver, I have already created an index "MongoIndex"
Issue: When I use NEST(.NET C#) to connect/fetch the data from ES, it returns 0 document whereas the same query returns result on REST.
MongoDB Details - DB: Enron Collection: Messages
ES Details- Index: MongoIndex Type: Messages
Single document format for a message in the collection -
{
"_id" : ObjectId("4f2ad4c4d1e2d3f15a000000"),
"body" : "Here is our forecast\n\n ",
"subFolder" : "allen-p/_sent_mail",
"mailbox" : "maildir",
"filename" : "1.",
"headers" : {
"X-cc" : "",
"From" : "[email protected]",
"Subject" : "",
"X-Folder" : "\\Phillip_Allen_Jan2002_1\\Allen, Phillip K.\\'Sent Mail",
"Content-Transfer-Encoding" : "7bit",
"X-bcc" : "",
"To" : "[email protected]",
"X-Origin" : "Allen-P",
"X-FileName" : "pallen (Non-Privileged).pst",
"X-From" : "Phillip K Allen",
"Date" : "Mon, 14 May 2001 16:39:00 -0700 (PDT)",
"X-To" : "Tim Belden ",
"Message-ID" : "<18782981.1075855378110.JavaMail.evans@thyme>",
"Content-Type" : "text/plain; charset=us-ascii",
"Mime-Version" : "1.0"
}
}
This is my .Net code for NEST to connect Elasticsearch -
public class Message
{
public string id { get; set; }
public string body { get; set; }
public string mailbox { get; set; }
public string filename { get; set; }
[ElasticProperty(Type = FieldType.Nested)]
public IList<HeadersComponent> headers { get; set; }
}
public class HeadersComponent
{
public string Cc { get; set; }
public string Bcc { get; set; }
public string From { get; set; }
public string Subject { get; set; }
public string To { get; set; }
public string Date { get; set; }
}
Uri node = new Uri("http://localhost:9200");
ConnectionSettings settings = new ConnectionSettings(node, "MongoIndex");
ElasticClient client = new ElasticClient(settings);
ISearchResponse<Message> searchResponse = client.Search<Message>(s => s.Query(q => q.Term(p => p.body, "SearchMe"));
When I run the above code to search for "SearchMe" text in the email 'body', it returns 0 results.
Need help on this. Its driving me nuts :)