Querying for Synonymic matches via LINQ
I am wondering if it is possible to perform synonymic queries via the LINQ provider.
I have something like
var queryParams = new QueryParams(); queryParams.Expression = query; queryParams.ExpandQuery = true;
and I would like to translate this into LINQ for readability. Is there some way to accomplish this?
I am looking for something along the lines of
var results = context.GetQueryable<SearchResultItem> .Where(x => x["myValue"].Contains(query)) .ExpandQuery(true)
or something to that effect. I found a comment in this post from December 2014 that indicated a request for this feature was in the pipeline; is it available currently or in the near future?
The expansion (using the thesaurus) of LINQ queries cannot be done on a per query basis but can be configured for all the Coveo for Sitecore LINQ queries in the
Coveo.SearchProvider.config file. The element name is
<ExpandQueries> and the values can be
false. If it doesn't exist in your configuration file, you can simply add it in the right section. Note that this element is supported from the January 2015 release (3.0.891) of Coveo for Sitecore. If you run an older release, you will need to upgrade.
<!-- Coveo Query configuration --> <queryConfiguration type="Coveo.Framework.Configuration.QueryConfiguration, Coveo.Framework"> ... <!-- The ExpandQueries element defines whether to expand queries (i.e. uses the thesaurus). --> <ExpandQueries>true</ExpandQueries> </queryConfiguration>