|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.Linq;
|
| 4 | +using Bogus; |
4 | 5 | using Examine;
|
| 6 | +using Lucene.Net.Util; |
5 | 7 | using Newtonsoft.Json;
|
6 | 8 | using NUnit.Framework;
|
7 | 9 | using Umbraco.Cms.Core.Models;
|
@@ -47,6 +49,43 @@ public void GivenValidationParentNode_WhenContentIndexedUnderDifferentParent_Doc
|
47 | 49 | }
|
48 | 50 | }
|
49 | 51 |
|
| 52 | + [Test] |
| 53 | + public void GivenIndexingDocument_WhenRichTextPropertyData_CanStoreImmenseFields() |
| 54 | + { |
| 55 | + using (GetSynchronousContentIndex(false, out UmbracoContentIndex index, out _, out ContentValueSetBuilder contentValueSetBuilder, null)) |
| 56 | + { |
| 57 | + index.CreateIndex(); |
| 58 | + |
| 59 | + ContentType contentType = ContentTypeBuilder.CreateBasicContentType(); |
| 60 | + contentType.AddPropertyType(new PropertyType(TestHelper.ShortStringHelper, "test", ValueStorageType.Ntext) |
| 61 | + { |
| 62 | + Alias = "rte", |
| 63 | + Name = "RichText", |
| 64 | + PropertyEditorAlias = Cms.Core.Constants.PropertyEditors.Aliases.TinyMce |
| 65 | + }); |
| 66 | + |
| 67 | + Content content = ContentBuilder.CreateBasicContent(contentType); |
| 68 | + content.Id = 555; |
| 69 | + content.Path = "-1,555"; |
| 70 | + |
| 71 | + var luceneStringFieldMaxLength = ByteBlockPool.BYTE_BLOCK_SIZE - 2; |
| 72 | + var faker = new Faker(); |
| 73 | + var immenseText = faker.Random.String(length: luceneStringFieldMaxLength + 10); |
| 74 | + |
| 75 | + content.Properties["rte"].SetValue(immenseText); |
| 76 | + |
| 77 | + IEnumerable<ValueSet> valueSet = contentValueSetBuilder.GetValueSets(content); |
| 78 | + index.IndexItems(valueSet); |
| 79 | + |
| 80 | + ISearchResults results = index.Searcher.CreateQuery().Id(555).Execute(); |
| 81 | + ISearchResult result = results.First(); |
| 82 | + |
| 83 | + var key = $"{UmbracoExamineFieldNames.RawFieldPrefix}rte"; |
| 84 | + Assert.IsTrue(result.Values.ContainsKey(key)); |
| 85 | + Assert.Greater(result.Values[key].Length, luceneStringFieldMaxLength); |
| 86 | + } |
| 87 | + } |
| 88 | + |
50 | 89 | [Test]
|
51 | 90 | public void GivenIndexingDocument_WhenGridPropertyData_ThenDataIndexedInSegregatedFields()
|
52 | 91 | {
|
|
0 commit comments