 | IFulltextQueryTDocumentMetadata Method |
Returns query metadata (data is available after the query has been executed).
Namespace: SphinxConnector.FluentApiAssembly: SphinxConnector (in SphinxConnector.dll) Version: 6.0.0
SyntaxIFulltextQuery<TDocument> Metadata(
out QueryMetadata metadata
)
Function Metadata (
<OutAttribute> ByRef metadata As QueryMetadata
) As IFulltextQuery(Of TDocument)
Parameters
- metadata QueryMetadata
- The metadata for this query.
Return Value
IFulltextQueryTDocumentThe current instance.
Example
Suppose you have the following class representing a document in your index:
And you want to retrieve the meta data along with the query:
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
var results = fulltextSession.Query<Product>().
Match("a product").
Metadata(out QueryMetadata metadata).
ToList();
}
Retrieving metadata with future queries:
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
var results = fulltextSession.Query<Product>().
Match("a product").
Metadata(out QueryMetadata resultsMetadata).
ToFutureList();
var facets = fulltextSession.Query<Product>().
Match("a product").
GroupBy(p => p.CategoryId).
Select(p => new
{
p.CategoryId,
Count = Projection.Count()
}).
Metadata(out QueryMetadata facetsMetadata).
ToFutureList();
foreach (result in results.Value) //<-- accessing the result of a query will cause all pending future queries
{ //to be executed in one roundtrip to Sphinx at this point
//...
}
}
See Also