public void IndexJsonDocument(BaristaIndexDefinition indexDefinition, JsonDocumentDto document)
 {
     ExecuteRestRequest("IndexJsonDocument", Method.POST, request => request.AddBody(new
     {
         indexDefinition,
         document
     }));
 }
        public static IEnumerable <BatchedDocument> ConvertJsonDocumentToLuceneDocument(IndexDefinition definition,
                                                                                        IEnumerable <JsonDocument> jsonDocuments)
        {
            var converter = new JsonDocumentToLuceneDocumentConverter(definition);

            return(jsonDocuments.Select(jsonDocument =>
            {
                var fields = converter.Index(jsonDocument, Field.Store.YES); // This might be No to save space..

                var luceneDoc = new Document();
                var documentIdField = new Field(Constants.DocumentIdFieldName, jsonDocument.DocumentId, Field.Store.YES,
                                                Field.Index.ANALYZED_NO_NORMS);
                luceneDoc.Add(documentIdField);

                var tempJsonDocument = new JsonDocumentDto
                {
                    DocumentId = jsonDocument.DocumentId,
                    MetadataAsJson = jsonDocument.Metadata.ToString(),
                    DataAsJson = jsonDocument.DataAsJson.ToString()
                };

                var jsonDocumentField = new Field(Constants.JsonDocumentFieldName, JsonConvert.SerializeObject(tempJsonDocument), Field.Store.YES,
                                                  Field.Index.NOT_ANALYZED_NO_NORMS);

                luceneDoc.Add(jsonDocumentField);

                foreach (var field in fields)
                {
                    luceneDoc.Add(field);
                }

                return new BatchedDocument
                {
                    DocumentId = jsonDocument.DocumentId,
                    Document = luceneDoc,
                    SkipDeleteFromIndex = false,
                };
            }));
        }
Ejemplo n.º 3
0
        public void IndexJsonDocument(BaristaIndexDefinition indexDefinition, JsonDocumentDto document)
        {
            try
            {
                if (document == null)
                {
                    throw new ArgumentNullException("document", @"A document must be specified.");
                }

                if (document.DocumentId.IsNullOrWhiteSpace())
                {
                    throw new InvalidOperationException(@"The json document must specify a document id.");
                }

                IndexJsonDocuments(indexDefinition, new List <JsonDocumentDto> {
                    document
                });
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
 public void IndexJsonDocument(BaristaIndexDefinition indexDefinition, JsonDocumentDto document)
 {
     Channel.IndexJsonDocument(indexDefinition, document);
 }