Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract Json property from RavenDB

I want to extract Json property from Raven DB database. I am extracting it from Ravendb studio from index as below. In below query, parameter Body is of type json and I want to extract its one field (let's say field1) from it. How can it be done?

from index 'Selectdata' as message 
order by message.ProcessedAt desc 
select {
    UniqueMessageId: message.UniqueMessageId,
    MessageId: message.MessageMetadata.MessageId,
    MessageType: message.Headers["EnclosedMessageTypes"],
    TimeSent: message.Headers["TimeSent"],
    ProcessingStarted: message.Headers["ProcessingStarted"],
    ProcessingEnded: message.Headers["ProcessingEnded"],
    ProcessingEndpoint: message.Headers["ProcessingEndpoint"],
    ProcessedAt : message.ProcessedAt,
    Body:message.MessageMetadata.Body //json body
}
like image 664
Rajaram Shelar Avatar asked Jul 27 '20 06:07

Rajaram Shelar


1 Answers

Use Full-Text-Search on the 'Body' field.
See code examples in the RavenDB Demo:

Full Text Search with Static Index - Single Field
https://demo.ravendb.net/demos/csharp/text-search/fts-with-static-index-single-field

Full Text Search with Static Index - Multiple Fields
https://demo.ravendb.net/demos/csharp/text-search/fts-with-static-index-multiple-fields

And also can use the Search() method on 'Body' field property. See https://ravendb.net/docs/article-page/5.0/Csharp/client-api/session/querying/how-to-use-search

like image 91
Danielle Avatar answered Oct 02 '22 16:10

Danielle