Reputation: 659
Help with Understanding RavenDB query, I'm using following model to store & index spatial data.
public class GeoRecord {
public string SearchId {get; set;}
public string Tag {get; set;}
public double Latitude {get; set;}
public double Longitude {get; set;}
}
public class GeoRecord_GeoIndex : AbstractIndexCreationTask<GeoRecord>
{
public GeoRecord_GeoIndex()
{
Map = records => from @record in records
select new
{
IndexName = "geoIndex",
record.SearchId,
Coordinates = CreateSpatialField(@record.Latitude, @record.Longitude)
};
}
}
I can able to filter all GeoRecord's using Spatial query like below:
await session
.Query<GeoRecord, GeoRecord_GeoIndex>()
.Spatial("Coordinates", factory => factory.Within(shapeWkt: wkt))
.ToListAsync();
However I would like to filter by both SearchId & Coordinates, I got this solution however I would like to understand if it uses GeoRecord_GeoIndex rather than filtering the results from GeoRecord.
await session.Advanced.AsyncDocumentQuery<GeoRecord, GeoRecord_GeoIndex>()
.WhereIn("SearchId", activeSearchIds)
.Intersect()
.Spatial("Coordinates", criteria => criteria.Within(shapeWkt:wkt))
.ToListAsync();
Upvotes: 2
Views: 51
Reputation: 3839
You are querying index GeoRecord_GeoIndex
, and it is the one used to filter.
A static index contains:
At query time, the indexed terms are filtered according to your query and the relevant documents are fetched from the database
some link to demo:
https://demo.ravendb.net/demos/csharp/static-indexes/map-index#step-3
Upvotes: 2