Gravatar for

Question by Dan Cruickshank, Jul 30, 2014 4:00 PM

Are the LINQ methods CoveoIn() or PhoenticMatch() implemented?

I was trying to understand how the methods work, and when I opened them I only saw:

public static bool CoveoIn<TSource, TIn, TKey>(this TSource p_Outfield, Expression<Func<TIn, TKey>> p_Infield, Expression<Func<TIn, bool>> p_Predicate)
  return true;
public static bool PhoneticMatch<TSource>(this TSource p_Value, string p_PhraseComparison)
      return true;

They're documented in the developers section, but I can't see how they'd work. Am I missing something? Thanks!

1 Reply
Gravatar for

Answer by Luc Bergeron, Jul 30, 2014 4:10 PM

This is normal. In fact, these methods act as stubs. They are meant to be part of a Linq expression. This way, they are parsed by the CoveoExpressionParser class and then transformed into query parameters that are given to CES.

Does it make more sense this way?

Gravatar for

Comment by Dan Cruickshank, Jul 30, 2014 4:27 PM

Thank you. This makes sense.

I'm doing a little write up, and was trying to understand the CoveoIn() method better to develop a use-case for it. For complex queries I've always used the PredicateBuilder.

Gravatar for

Comment by Dan Cruickshank, Jul 30, 2014 4:43 PM

Follow-up! (sorry if this is out of context)

With LINQ + Coveo how do you do a free-text keyword search against a coveo document, not just against a field? It seems like .ContainsKeyword() is field based. I liked to search the whole document.

With Lucene I'd query the document["_content"] field.


Gravatar for

Comment by Vincent Séguin, Jul 30, 2014 4:52 PM

Hi Dan,

If the data you want to search is in the body of your document, then it is free-text automatically. You could do a regular query (not on a field) and it will search in the content.

You can use the CoveoPostItemProcessingPipeline to edit the body of documents. See pipelines documented here :

You just have to set what you want in the BinaryData property of the CoveoIndexableItem that is passed in the pipeline.

Gravatar for

Comment by Vincent Séguin, Jul 30, 2014 5:09 PM

About my last comment, that wouldn't work so well, since you can't do a LINQ query based on something else than a field… we could add an extension to do it.

Meanwhile, i think your best bet would be to create a computed field that leverages what you need, and configure it as free text in your Coveo.SearchProvider.config file. I guess this is also something that could come OOTB.

See documentation on computed fields there if needed :

Gravatar for

Comment by Nicolas, Jul 31, 2014 12:16 PM

Hi Dan,

Actually, the field _content is the exception to the rule. If you query on this field its translated to a free-text query. We'll definitely need to document this one on!

So an expression like this :

queryable.Where(item => item["_content"] == "\"search page\"");

is translated to this :

("search page")

Thanks, Nick

Gravatar for

Comment by Dan Cruickshank, Jul 31, 2014 12:25 PM

Thanks Nick. That's great.

Like I mentioned, that's how we do it with Lucene + Sitecore. So this is pretty straight forward. :)

I'll probably post about this as well.

Ask a question