Frage

When I try to take the 10 latest results (oder by date desc) from my index, I receive old documents. It look like the query take 10 outdated items and sort it. I have this problem when the query have many results to play with.

Here's my index definition:

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) };
    }
}

I call my index using this code:

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>();
}
War es hilfreich?

Lösung

This post appears to be describing the normal behavior of stale indexes.

This is not related at all to spatial indexes. That just happens to be the index that is stale.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top