Query searchd with SphinxQL.

Namespace: Gronewold.SphinxConnector
Assembly: Gronewold.SphinxConnector (in Gronewold.SphinxConnector.dll) Version: 2.8.0.26312 (2.8.0.26312)

Syntax

C#
[ObsoleteAttribute("SphinxQL queries will longer be supported with Sphinx 2.0.1. Please use the classes from the SphinxQL namespace to access Sphinx via SphinxQL.")]
public SphinxSearchResult QueryWithSphinxQL(
	string query
)
Visual Basic
<ObsoleteAttribute("SphinxQL queries will longer be supported with Sphinx 2.0.1. Please use the classes from the SphinxQL namespace to access Sphinx via SphinxQL.")> _
Public Function QueryWithSphinxQL ( _
	query As String _
) As SphinxSearchResult

Parameters

query
Type: System..::..String
The query to execute.

Return Value

An instance of the SphinxSearchResult class with the query result.

Remarks

Note that the options given by the SearchOptions property are not applied to SphinxQL queries. Use OPTIONS optionname=value in the query instead.

Examples

CopyC#
SphinxClient sphinxClient = new SphinxClient(); 
SphinxSearchResult result = sphinxClient.QueryWithSphinxQL("SELECT * FROM sakila WHERE MATCH('room')");

foreach (SphinxMatch match in result.Matches)
{
    Console.WriteLine("DocumentId {0} Weight {1}", match.DocumentId, match.Weight);
}
The following example uses the Sphinx specific OPTION extension to set some options for the query:
CopyC#
SphinxClient sphinxClient = new SphinxClient(); 
SphinxSearchResult result = sphinxClient.QueryWithSphinxQL(@"SELECT * FROM sakila 
                                                             WHERE MATCH('room') 
                                                             OPTION ranker=bm25, max_matches=50");

foreach (SphinxMatch match in result.Matches)
{
    Console.WriteLine("DocumentId {0} Weight {1}", match.DocumentId, match.Weight);
}

Exceptions

ExceptionCondition
System..::..ArgumentExceptionquery is empty.
System..::..ArgumentNullExceptionquery is null.
System..::..NotSupportedExceptionVersion is less than 0.9.9.
Gronewold.SphinxConnector..::..SphinxClientException An error occured while executing the query. See exception message and inner exception for details.

See Also