 | ISphinxQLExecutor.QueryMulti Method |
Executes the given SphinxQL multi-query and returns an instance of
MultiQueryResult that can be used to
retrieve the results for the queries.
Namespace: SphinxConnector.FluentApiAssembly: SphinxConnector (in SphinxConnector.dll) Version: 3.12.6
SyntaxMultiQueryResult QueryMulti(
string multiQuery,
Object parameters = null
)
Function QueryMulti (
multiQuery As String,
Optional parameters As Object = Nothing
) As MultiQueryResult
Parameters
- multiQuery
- Type: System.String
The multi-query to execute. - parameters (Optional)
- Type: System.Object
The (optional) parameters for the query.
Return Value
Type:
MultiQueryResultAn instance of
MultiQueryResult that can be used to retrieve the results for the queries.
Exceptions
Examples
Suppose you have the following class representing a document in your index:
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; }
}
You want to execute a full-text query over your products and retrieve some facets along with it by using Sphinx' FACET-clause that was introduced with Sphinx 2.2.3:
public class VendorFacet
{
public int Count { get; set; }
public int VendorId { get; set; }
}
public class CategoryFacet
{
public int Count { get; set; }
public int CategoryId { get; set; }
}
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
ISphinxQLExecutor sphinxQLExecutor = fulltextSession.Advanced.CreateSphinxQLExecutor();
var parameters = new { query = "a product" };
using (var multiQueryResult = sphinxQLExecutor.QueryMulti(@"SELECT * FROM products WHERE MATCH(@query)
FACET CategoryId
FACET VendorId", parameters))
{
var productMatches = multiQueryResult.Read<Product>();
var categoryFacets = multiQueryResult.Read<CategoryFacet>();
var vendorFacets = multiQueryResult.Read<VendorFacet>();
}
}
Remarks
Note that the method automatically maps the 'count(*)' result column from the facet result to the 'Count' column of the respective objects.
See Also