当我尝试从我的索引中获取 10 个最新结果(按日期顺序排列)时,我收到了旧文档。看起来查询需要 10 个过时的项目并对其进行排序。当查询有很多结果可供使用时,我遇到了这个问题。
这是我的索引定义:
public class Home_ByCategoryTagAndLocation : AbstractIndexCreationTask<Home>
{
public Home_ByCategoryTagAndLocation()
{
Map = home => from n in home
from t in n.Source.CategoryTag
from c in n.Locations
select new { CategoryTag = t, n.DatePublished, _ = SpatialIndex.Generate(c.Latitude, c.Longitude) };
}
}
我使用以下代码调用我的索引:
public static List<Home> GetLatestHomeNear(IDocumentStore store, CityLocation location, int maxResults = 15)
{
if (location != null)
{
using (IDocumentSession session = store.OpenSession())
{
return session.Advanced.LuceneQuery<Home>("Home/ByCategoryTagAndLocation")
.WithinRadiusOf(radius: location.DefaultRadius, latitude: location.Latitude, longitude: location.Longitude)
.OrderByDescending(n => n.DatePublished)
.Take(maxResults)
.ToList();
}
}
return new List<Home>();
}