0
2つのタグがそれぞれ2つのドキュメントがあるとします。Lucene.net 4.8:重要なファセットフィールドを追加する順序?
のDoc 1:タグ1、タグ2 ドク2:タグ2、タグ1
私はこのようluceneのでドキュメントを構築しています:ファセットを取得
var doc = new Document
{
new StoredField("Id", blogPost.Id),
new Int32Field("ModuleId", blogPost.ModuleId, Field.Store.YES),
new TextField("Title", blogPost.Title, Field.Store.YES),
new StringField("Slug", blogPost.Slug, Field.Store.YES),
new StoredField("ImagePath", blogPost.ImagePath),
new TextField("Intro", blogPost.Intro, Field.Store.YES),
new TextField("Html", blogPost.Title, Field.Store.YES),
new Int64Field("PublishDate", blogPost.PublishDate.Ticks, Field.Store.YES),
new FacetField("PublishDateTag", blogPost.PublishDate.Year.ToString(), blogPost.PublishDate.Month.ToString(), blogPost.PublishDate.Year.ToString())
};
foreach (var tag in blogPost.TagObjects)
{
doc.Add(new Int32AssociationFacetField(1,"Tags", tag.Name));
doc.Add(new StringField("Tag", tag.Name, Field.Store.YES));
doc.Add(new Int32AssociationFacetField(1, "TagSlugs", tag.Slug));
doc.Add(new StringField("TagSlug", tag.Slug, Field.Store.YES));
は、私として活躍されていませんタフしたい。私はこのような検索を行うとき:
var facetsConfig = ConfigFacets();
IList<FacetResult> results = new List<FacetResult>();
using (var indexReader = DirectoryReader.Open(IndexDir))
using (var taxoReader = new DirectoryTaxonomyReader(TaxoDir))
{
var searcher = new IndexSearcher(indexReader);
var facetsCollector = new FacetsCollector();
// MatchAllDocsQuery is for "browsing" (counts facets
// for all non-deleted docs in the index); normally
// you'd use a "normal" query:
FacetsCollector.Search(searcher, new MatchAllDocsQuery(), 10, facetsCollector);
// Retrieve results
Facets tags = new TaxonomyFacetSumInt32Associations("$tag", taxoReader, facetsConfig, facetsCollector);
results.Add(tags.GetTopChildren(10, "Tags"));
} // Disposes indexReader and taxoReader
if (results[0] == null)
return new Dictionary<string, int>();
return results.Where(x => x.Dim == "Tags").SelectMany(x => x.LabelValues).ToDictionary(x => x.Label, x => Convert.ToInt32(x.Value));
を次のように結果は次のとおりです。タグ1は、(1)、タグ1(1)、タグ2(1)、タグ2(1)
に見えますタグの順序がどうにかして役割を果たすように、私は絶対に望んでいない。これをどうすれば解決できますか?
私を助ける人は誰もいない:( – brechtvhb