IFulltext QueryTDocumentMetadata Method
Returns query metadata (data is available after the query has been executed).
Definition
Namespace: SphinxConnector.FluentApi
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.3.0
The current instance.
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.3.0
C#
IFulltextQuery<TDocument> Metadata(
out QueryMetadata metadata
)VB
Function Metadata (
<OutAttribute> ByRef metadata As QueryMetadata
) As IFulltextQuery(Of TDocument)Parameters
- metadata QueryMetadata
- The metadata for this query.
Return Value
IFulltextQueryTDocumentThe current instance.
Remarks
Note that as of V3 Sphinx only supports retrieving metadata for the most recent query, so the above example only works with Manticore Search.
With Sphinx you'd have to execute the queries separately, i.e. without the future queries feature.
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:
Retrieving metadata with future queries:
C#
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
public int CategoryId { get; set; }
public int VendorId { get; set; }
public int Weight { get; set; }
}
And you want to retrieve the meta data along with the query:
C#
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
var results = fulltextSession.Query<Product>().
Match("a product").
Metadata(out QueryMetadata metadata).
ToList();
}Retrieving metadata with future queries:
C#
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
//...
}
}