Configured tokenization and storage for current indexed fields

Properties like dates, and slug should not be tokenized. Body is not stored.

--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-06-02 17:17:40 -07:00
parent cb3ab26859
commit 8ce241434b
4 changed files with 23 additions and 8 deletions

View File

@@ -142,5 +142,20 @@ namespace Orchard.Tests.Indexing {
Assert.IsNull(_provider.CreateSearchBuilder("default3").Get(1)); Assert.IsNull(_provider.CreateSearchBuilder("default3").Get(1));
} }
[Test]
public void IdentifierShouldNotCollide() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("field", "value1"));
_provider.Store("default", _provider.New(11).Add("field", "value11"));
_provider.Store("default", _provider.New(111).Add("field", "value111"));
var searchBuilder = _provider.CreateSearchBuilder("default");
Assert.That(searchBuilder.Get(1).Id, Is.EqualTo(1));
Assert.That(searchBuilder.Get(11).Id, Is.EqualTo(11));
Assert.That(searchBuilder.Get(111).Id, Is.EqualTo(111));
}
} }
} }

View File

@@ -10,8 +10,8 @@ namespace Orchard.Core.Common.Handlers {
Filters.Add(StorageFilter.For(bodyRepository)); Filters.Add(StorageFilter.For(bodyRepository));
OnIndexing<BodyAspect>((context, bodyAspect) => context.IndexDocument OnIndexing<BodyAspect>((context, bodyAspect) => context.IndexDocument
.Add("body", bodyAspect.Record.Text) .Add("body", bodyAspect.Record.Text).Store(false)
.Add("format", bodyAspect.Record.Format)); .Add("format", bodyAspect.Record.Format).Analyze(false));
} }
} }
} }

View File

@@ -56,11 +56,11 @@ namespace Orchard.Core.Common.Handlers {
OnUpdateEditorViewModel<CommonAspect>(UpdateEditor); OnUpdateEditorViewModel<CommonAspect>(UpdateEditor);
OnIndexing<CommonAspect>((context, commonAspect) => context.IndexDocument OnIndexing<CommonAspect>((context, commonAspect) => context.IndexDocument
.Add("type", commonAspect.ContentItem.ContentType) .Add("type", commonAspect.ContentItem.ContentType).Analyze(false)
.Add("author", commonAspect.Owner.UserName) .Add("author", commonAspect.Owner.UserName).Analyze(false)
.Add("created", commonAspect.CreatedUtc ?? _clock.UtcNow) .Add("created", commonAspect.CreatedUtc ?? _clock.UtcNow).Analyze(false)
.Add("published", commonAspect.PublishedUtc ?? _clock.UtcNow) .Add("published", commonAspect.PublishedUtc ?? _clock.UtcNow).Analyze(false)
.Add("modified", commonAspect.ModifiedUtc ?? _clock.UtcNow) .Add("modified", commonAspect.ModifiedUtc ?? _clock.UtcNow).Analyze(false))
); );
} }

View File

@@ -37,7 +37,7 @@ namespace Orchard.Core.Common.Handlers {
OnCreated<RoutableAspect>((context, ra) => routableService.ProcessSlug(ra)); OnCreated<RoutableAspect>((context, ra) => routableService.ProcessSlug(ra));
OnIndexing<RoutableAspect>((context, part) => context.IndexDocument OnIndexing<RoutableAspect>((context, part) => context.IndexDocument
.Add("slug", part.Slug) .Add("slug", part.Slug).Analyze(false)
.Add("title", part.Title) .Add("title", part.Title)
); );
} }