当我尝试从索引中获取10个最新结果(oder by date desc)时,我会收到旧文档。它看起来像查询需要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>();
}