IFulltext QueryTDocumentOptions Method
Change the options used for this query.
Definition
Namespace: SphinxConnector.FluentApi
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
The current instance.
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
C#
IFulltextQuery<TDocument> Options(
Action<IFulltextQueryOptions<TDocument>> optionSetter
)VB
Function Options (
optionSetter As Action(Of IFulltextQueryOptions(Of TDocument))
) As IFulltextQuery(Of TDocument)Parameters
- optionSetter ActionIFulltextQueryOptionsTDocument
- A function to set the options.
Return Value
IFulltextQueryTDocumentThe current instance.
Example
Suppose you have the following class representing a document in your index:
And you want to set a custom field weight for the name attribute and set max matches to 50:
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 set a custom field weight for the name attribute and set max matches to 50:
C#
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
var results = fulltextSession.Query<Product>().
Match("a product").
Options(o => o.FieldWeight(x => x.Name, 1000).
MaxMatches(50)).
ToList();
}