Partial match in coveo query
I have used below code for my partial match query builder::
var searchterm = 'co'; var myQueryBuilder = new Coveo.Ui.QueryBuilder(); myQueryBuilder.expression.add(searchterm); myQueryBuilder.partialMatchKeywords = 2; myQueryBuilder.partialMatchThreshold = '50%'; myQueryBuilder.enablePartialMatch= true; var myQuery = myQueryBuilder.build();
My serach term is 'co' and i am not getting atricles having data like 'Commission Timing' .but when i type 'com' i am getting expected result.Any suggestion will be helpful.
I think you are using the wrong options for the job you try to get done. The
[enablePartialMatch] option is not meant to search for words beginning with a few characters. Here's what the documentation say about this option:
Boolean value to specify if you want to enable partial match for this query. When partial match is disabled, all the keywords in a query are present in the returned documents. When partial match is enabled, the returned documents can include only some of the query keywords.
This feature is particularly useful when users enter queries with a large number of keywords, such as when they copy a sentence or a message and paste it in the search box. When no documents contain the copied content, having a large number of keywords significantly narrows search results. With the enabled partial match, documents containing only some of the important keywords are also returned.
Note: This partial match feature does not perform partial match within a keyword. You can achieve keyword partial match by turning on enableWildcards in a search box to allow users to include wildcard characters in their queries (see enableWildcards).
What you try to do is finding results which contains a word starting by a few characters ("co" in your example). This can be done with wildcards and the enableWildcards option. This option requires the terms of your search expression to contains wildcard characters (* and ? if the
questionMark option is set to true in the query parameters). Your example search expression should be "
co*" for this option.