Gravatar for debadyuti.sil@gmail.com

Question by Deb, Sep 24, 2015 4:21 PM

Partial match in coveo query

Hi,

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.

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Sep 24, 2015 4:36 PM

Hi,

I think you are using the wrong options for the job you try to get done. The [enablePartialMatch][1] 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.

Gravatar for debadyuti.sil@gmail.com

Comment by Deb, Sep 24, 2015 5:10 PM

Hi jflheureux,

Thanks for your reply.I added 2 more parameters in by querybuild as :

myQueryBuilder.enableWildcards= true;
myQueryBuilder.wildcards = '*';

Still it's not returning 'ciommisions' when searchterm is 'co*' .Any guess?

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Sep 24, 2015 5:25 PM

  1. There's no wildcards parameter on the QueryBuilder object. Please refer to the documentation.
  2. When you call var myQuery = myQueryBuilder.build();, your myQuery object should have its wildcards property set to true.
  3. What are you doing with your myQuery object after your code?
Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Sep 24, 2015 5:25 PM

You may not get any result but a query exception with this "co*" very general query. This is because the index will reject your query if more than 32 indexed words begin with the letters "co". This is a default setting of the index (see Modifying or Using Advanced Index Parameters)

Ask a question