Gravatar for

Question by cmgutmanis, Jul 16, 2015 3:02 PM

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))

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?

Thanks again!

1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Jul 16, 2015 6:07 PM

Hi Christopher,

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 true or 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). -->
Ask a question